{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "\n",
    "from numpy import *\n",
    "from numpy import linalg as la"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "class RecommendSystem:\n",
    "    def __init__(self):\n",
    "        self.userIndex = cPickle.load(open(\"userIndex.pkl\", 'rb'))\n",
    "        self.eventIndex = cPickle.load(open(\"eventIndex.pkl\", 'rb'))\n",
    "        self.n_users = len(self.userIndex)\n",
    "        self.n_items = len(self.eventIndex)\n",
    "        self.userEventScores = sio.mmread(\"PE_userEventScores\").todense()\n",
    "        self.itemsForUser = cPickle.load(open(\"PE_eventsForUser.pkl\", 'rb'))\n",
    "        self.usersForItem = cPickle.load(open(\"PE_usersForEvent.pkl\", 'rb'))\n",
    "        self.init_SVD()\n",
    "        self.train_SVD(trainfile = \"train.csv\")\n",
    "        self.userSimMatrix = sio.mmread(\"US_userSimMatrix\").todense()\n",
    "        self.eventPropSim = sio.mmread(\"EV_eventPropSim\").todense()\n",
    "        self.eventContSim = sio.mmread(\"EV_eventContSim\").todense()\n",
    "        self.numFriends = sio.mmread(\"UF_numFriends\")\n",
    "        self.userFriends = sio.mmread(\"UF_userFriends\").todense()\n",
    "        self.eventPopularity = sio.mmread(\"EA_eventPopularity\").todense()\n",
    "    \n",
    "    \n",
    "    def itemSim(self, data, uid, simMeans, item):\n",
    "        data = self.userEventScores\n",
    "        n = shape(data)[1]\n",
    "        simTotal = 0.0\n",
    "        ratSimTotal = 0.0\n",
    "        for j in range(n):\n",
    "            userRating = data[user,uid]\n",
    "            if userRating ==0:\n",
    "                continue\n",
    "            overLap = nonzero(logical_and(data[:,item].A>0, data[:,j].A>0))[0]\n",
    "            "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>user</th>\n",
       "      <th>event</th>\n",
       "      <th>invited</th>\n",
       "      <th>timestamp</th>\n",
       "      <th>interested</th>\n",
       "      <th>not_interested</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>3044012</td>\n",
       "      <td>1918771225</td>\n",
       "      <td>0</td>\n",
       "      <td>2012-10-02 15:53:05.754000+00:00</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>3044012</td>\n",
       "      <td>1502284248</td>\n",
       "      <td>0</td>\n",
       "      <td>2012-10-02 15:53:05.754000+00:00</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3044012</td>\n",
       "      <td>2529072432</td>\n",
       "      <td>0</td>\n",
       "      <td>2012-10-02 15:53:05.754000+00:00</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>3044012</td>\n",
       "      <td>3072478280</td>\n",
       "      <td>0</td>\n",
       "      <td>2012-10-02 15:53:05.754000+00:00</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>3044012</td>\n",
       "      <td>1390707377</td>\n",
       "      <td>0</td>\n",
       "      <td>2012-10-02 15:53:05.754000+00:00</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      user       event  invited                         timestamp  interested  \\\n",
       "0  3044012  1918771225        0  2012-10-02 15:53:05.754000+00:00           0   \n",
       "1  3044012  1502284248        0  2012-10-02 15:53:05.754000+00:00           0   \n",
       "2  3044012  2529072432        0  2012-10-02 15:53:05.754000+00:00           1   \n",
       "3  3044012  3072478280        0  2012-10-02 15:53:05.754000+00:00           0   \n",
       "4  3044012  1390707377        0  2012-10-02 15:53:05.754000+00:00           0   \n",
       "\n",
       "   not_interested  \n",
       "0               0  \n",
       "1               0  \n",
       "2               0  \n",
       "3               0  \n",
       "4               0  "
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train = pd.read_csv(\"train.csv\")\n",
    "train.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 15398 entries, 0 to 15397\n",
      "Data columns (total 6 columns):\n",
      "user              15398 non-null int64\n",
      "event             15398 non-null int64\n",
      "invited           15398 non-null int64\n",
      "timestamp         15398 non-null object\n",
      "interested        15398 non-null int64\n",
      "not_interested    15398 non-null int64\n",
      "dtypes: int64(5), object(1)\n",
      "memory usage: 721.9+ KB\n"
     ]
    }
   ],
   "source": [
    "train.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>user</th>\n",
       "      <th>event</th>\n",
       "      <th>invited</th>\n",
       "      <th>timestamp</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1776192</td>\n",
       "      <td>2877501688</td>\n",
       "      <td>0</td>\n",
       "      <td>2012-11-30 11:39:01.230000+00:00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1776192</td>\n",
       "      <td>3025444328</td>\n",
       "      <td>0</td>\n",
       "      <td>2012-11-30 11:39:01.230000+00:00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1776192</td>\n",
       "      <td>4078218285</td>\n",
       "      <td>0</td>\n",
       "      <td>2012-11-30 11:39:01.230000+00:00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1776192</td>\n",
       "      <td>1024025121</td>\n",
       "      <td>0</td>\n",
       "      <td>2012-11-30 11:39:01.230000+00:00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1776192</td>\n",
       "      <td>2972428928</td>\n",
       "      <td>0</td>\n",
       "      <td>2012-11-30 11:39:21.985000+00:00</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      user       event  invited                         timestamp\n",
       "0  1776192  2877501688        0  2012-11-30 11:39:01.230000+00:00\n",
       "1  1776192  3025444328        0  2012-11-30 11:39:01.230000+00:00\n",
       "2  1776192  4078218285        0  2012-11-30 11:39:01.230000+00:00\n",
       "3  1776192  1024025121        0  2012-11-30 11:39:01.230000+00:00\n",
       "4  1776192  2972428928        0  2012-11-30 11:39:21.985000+00:00"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "test = pd.read_csv(\"test.csv\")\n",
    "test.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>user_id</th>\n",
       "      <th>locale</th>\n",
       "      <th>birthyear</th>\n",
       "      <th>gender</th>\n",
       "      <th>joinedAt</th>\n",
       "      <th>location</th>\n",
       "      <th>timezone</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>3197468391</td>\n",
       "      <td>id_ID</td>\n",
       "      <td>1993</td>\n",
       "      <td>male</td>\n",
       "      <td>2012-10-02T06:40:55.524Z</td>\n",
       "      <td>Medan  Indonesia</td>\n",
       "      <td>480.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>3537982273</td>\n",
       "      <td>id_ID</td>\n",
       "      <td>1992</td>\n",
       "      <td>male</td>\n",
       "      <td>2012-09-29T18:03:12.111Z</td>\n",
       "      <td>Medan  Indonesia</td>\n",
       "      <td>420.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>823183725</td>\n",
       "      <td>en_US</td>\n",
       "      <td>1975</td>\n",
       "      <td>male</td>\n",
       "      <td>2012-10-06T03:14:07.149Z</td>\n",
       "      <td>Stratford  Ontario</td>\n",
       "      <td>-240.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1872223848</td>\n",
       "      <td>en_US</td>\n",
       "      <td>1991</td>\n",
       "      <td>female</td>\n",
       "      <td>2012-11-04T08:59:43.783Z</td>\n",
       "      <td>Tehran  Iran</td>\n",
       "      <td>210.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>3429017717</td>\n",
       "      <td>id_ID</td>\n",
       "      <td>1995</td>\n",
       "      <td>female</td>\n",
       "      <td>2012-09-10T16:06:53.132Z</td>\n",
       "      <td>NaN</td>\n",
       "      <td>420.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      user_id locale birthyear  gender                  joinedAt  \\\n",
       "0  3197468391  id_ID      1993    male  2012-10-02T06:40:55.524Z   \n",
       "1  3537982273  id_ID      1992    male  2012-09-29T18:03:12.111Z   \n",
       "2   823183725  en_US      1975    male  2012-10-06T03:14:07.149Z   \n",
       "3  1872223848  en_US      1991  female  2012-11-04T08:59:43.783Z   \n",
       "4  3429017717  id_ID      1995  female  2012-09-10T16:06:53.132Z   \n",
       "\n",
       "             location  timezone  \n",
       "0    Medan  Indonesia     480.0  \n",
       "1    Medan  Indonesia     420.0  \n",
       "2  Stratford  Ontario    -240.0  \n",
       "3        Tehran  Iran     210.0  \n",
       "4                 NaN     420.0  "
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "users = pd.read_csv(\"users.csv\")\n",
    "users.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 38209 entries, 0 to 38208\n",
      "Data columns (total 7 columns):\n",
      "user_id      38209 non-null int64\n",
      "locale       38209 non-null object\n",
      "birthyear    38209 non-null object\n",
      "gender       38100 non-null object\n",
      "joinedAt     38152 non-null object\n",
      "location     32745 non-null object\n",
      "timezone     37773 non-null float64\n",
      "dtypes: float64(1), int64(1), object(5)\n",
      "memory usage: 2.0+ MB\n"
     ]
    }
   ],
   "source": [
    "users.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>event_id</th>\n",
       "      <th>user_id</th>\n",
       "      <th>start_time</th>\n",
       "      <th>city</th>\n",
       "      <th>state</th>\n",
       "      <th>zip</th>\n",
       "      <th>country</th>\n",
       "      <th>lat</th>\n",
       "      <th>lng</th>\n",
       "      <th>c_1</th>\n",
       "      <th>...</th>\n",
       "      <th>c_92</th>\n",
       "      <th>c_93</th>\n",
       "      <th>c_94</th>\n",
       "      <th>c_95</th>\n",
       "      <th>c_96</th>\n",
       "      <th>c_97</th>\n",
       "      <th>c_98</th>\n",
       "      <th>c_99</th>\n",
       "      <th>c_100</th>\n",
       "      <th>c_other</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>684921758</td>\n",
       "      <td>3647864012</td>\n",
       "      <td>2012-10-31T00:00:00.001Z</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>244999119</td>\n",
       "      <td>3476440521</td>\n",
       "      <td>2012-11-03T00:00:00.001Z</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3928440935</td>\n",
       "      <td>517514445</td>\n",
       "      <td>2012-11-05T00:00:00.001Z</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2582345152</td>\n",
       "      <td>781585781</td>\n",
       "      <td>2012-10-30T00:00:00.001Z</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1051165850</td>\n",
       "      <td>1016098580</td>\n",
       "      <td>2012-09-27T00:00:00.001Z</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 110 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     event_id     user_id                start_time city state  zip country  \\\n",
       "0   684921758  3647864012  2012-10-31T00:00:00.001Z  NaN   NaN  NaN     NaN   \n",
       "1   244999119  3476440521  2012-11-03T00:00:00.001Z  NaN   NaN  NaN     NaN   \n",
       "2  3928440935   517514445  2012-11-05T00:00:00.001Z  NaN   NaN  NaN     NaN   \n",
       "3  2582345152   781585781  2012-10-30T00:00:00.001Z  NaN   NaN  NaN     NaN   \n",
       "4  1051165850  1016098580  2012-09-27T00:00:00.001Z  NaN   NaN  NaN     NaN   \n",
       "\n",
       "   lat  lng  c_1   ...     c_92  c_93  c_94  c_95  c_96  c_97  c_98  c_99  \\\n",
       "0  NaN  NaN    2   ...        0     1     0     0     0     0     0     0   \n",
       "1  NaN  NaN    2   ...        0     0     0     0     0     0     0     0   \n",
       "2  NaN  NaN    0   ...        0     0     0     0     0     0     0     0   \n",
       "3  NaN  NaN    1   ...        0     0     0     0     0     0     0     0   \n",
       "4  NaN  NaN    1   ...        0     0     0     0     0     0     0     0   \n",
       "\n",
       "   c_100  c_other  \n",
       "0      0        9  \n",
       "1      0        7  \n",
       "2      0       12  \n",
       "3      0        8  \n",
       "4      0        9  \n",
       "\n",
       "[5 rows x 110 columns]"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "events = pd.read_csv(\"events.csv\")\n",
    "events.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>event</th>\n",
       "      <th>yes</th>\n",
       "      <th>maybe</th>\n",
       "      <th>invited</th>\n",
       "      <th>no</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1159822043</td>\n",
       "      <td>1975964455 252302513 4226086795 3805886383 142...</td>\n",
       "      <td>2733420590 517546982 1350834692 532087573 5831...</td>\n",
       "      <td>1723091036 3795873583 4109144917 3560622906 31...</td>\n",
       "      <td>3575574655 1077296663</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>686467261</td>\n",
       "      <td>2394228942 2686116898 1056558062 3792942231 41...</td>\n",
       "      <td>1498184352 645689144 3770076778 331335845 4239...</td>\n",
       "      <td>1788073374 733302094 1830571649 676508092 7081...</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1186208412</td>\n",
       "      <td>NaN</td>\n",
       "      <td>3320380166 3810793697</td>\n",
       "      <td>1379121209 440668682</td>\n",
       "      <td>1728988561 2950720854</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2621578336</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>855842686</td>\n",
       "      <td>2406118796 3550897984 294255260 1125817077 109...</td>\n",
       "      <td>2671721559 1761448345 2356975806 2666669465 10...</td>\n",
       "      <td>1518670705 880919237 2326414227 2673818347 332...</td>\n",
       "      <td>3500235232</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        event                                                yes  \\\n",
       "0  1159822043  1975964455 252302513 4226086795 3805886383 142...   \n",
       "1   686467261  2394228942 2686116898 1056558062 3792942231 41...   \n",
       "2  1186208412                                                NaN   \n",
       "3  2621578336                                                NaN   \n",
       "4   855842686  2406118796 3550897984 294255260 1125817077 109...   \n",
       "\n",
       "                                               maybe  \\\n",
       "0  2733420590 517546982 1350834692 532087573 5831...   \n",
       "1  1498184352 645689144 3770076778 331335845 4239...   \n",
       "2                              3320380166 3810793697   \n",
       "3                                                NaN   \n",
       "4  2671721559 1761448345 2356975806 2666669465 10...   \n",
       "\n",
       "                                             invited                     no  \n",
       "0  1723091036 3795873583 4109144917 3560622906 31...  3575574655 1077296663  \n",
       "1  1788073374 733302094 1830571649 676508092 7081...                    NaN  \n",
       "2                               1379121209 440668682  1728988561 2950720854  \n",
       "3                                                NaN                    NaN  \n",
       "4  1518670705 880919237 2326414227 2673818347 332...             3500235232  "
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "events_attendees = pd.read_csv(\"event_attendees.csv\")\n",
    "events_attendees.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>user</th>\n",
       "      <th>friends</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>3197468391</td>\n",
       "      <td>1346449342 3873244116 4226080662 1222907620 54...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>3537982273</td>\n",
       "      <td>1491560444 395798035 2036380346 899375619 3534...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>823183725</td>\n",
       "      <td>1484954627 1950387873 1652977611 4185960823 42...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1872223848</td>\n",
       "      <td>83361640 723814682 557944478 1724049724 253059...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>3429017717</td>\n",
       "      <td>4253303705 2130310957 1838389374 3928735761 71...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "         user                                            friends\n",
       "0  3197468391  1346449342 3873244116 4226080662 1222907620 54...\n",
       "1  3537982273  1491560444 395798035 2036380346 899375619 3534...\n",
       "2   823183725  1484954627 1950387873 1652977611 4185960823 42...\n",
       "3  1872223848  83361640 723814682 557944478 1724049724 253059...\n",
       "4  3429017717  4253303705 2130310957 1838389374 3928735761 71..."
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "user_friends = pd.read_csv(\"user_friends.csv\")\n",
    "user_friends.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import pickle\n",
    "import itertools\n",
    "import datetime\n",
    "import numpy as np\n",
    "import scipy.io as sio\n",
    "import scipy.sparse as ss\n",
    "import scipy.spatial.distance as ssd\n",
    "from collections import defaultdict\n",
    "from sklearn.preprocessing import normalize"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "uniqueUsers = set()\n",
    "uniqueEvents = set()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "eventsForUser = defaultdict(set)\n",
    "usersForEvent = defaultdict(set)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "for filename in [\"train.csv\",\"test.csv\"]:\n",
    "    f = open(filename,\"r\")\n",
    "    f.readline().strip().split(\",\")\n",
    "    for line in f:\n",
    "        cols = line.strip().split(\",\")\n",
    "        uniqueUsers.add(cols[0])\n",
    "        uniqueEvents.add(cols[1])\n",
    "    f.close()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'3272389348',\n",
       " '584188387',\n",
       " '2344133160',\n",
       " '1742267789',\n",
       " '1184737011',\n",
       " '3377526627',\n",
       " '4289419892',\n",
       " '1953311106',\n",
       " '4045020395',\n",
       " '3251840412',\n",
       " '4268968909',\n",
       " '1190190812',\n",
       " '320000323',\n",
       " '320069736',\n",
       " '3138500404',\n",
       " '3808055269',\n",
       " '4199616576',\n",
       " '2836886911',\n",
       " '2895220130',\n",
       " '4286635694',\n",
       " '3849582471',\n",
       " '1933513142',\n",
       " '4244109605',\n",
       " '2030266367',\n",
       " '4055395044',\n",
       " '2285462405',\n",
       " '71688472',\n",
       " '2321085380',\n",
       " '2243518535',\n",
       " '3245449378',\n",
       " '1847477018',\n",
       " '3108480638',\n",
       " '4246728549',\n",
       " '3969445925',\n",
       " '2006663136',\n",
       " '1515805774',\n",
       " '1851530247',\n",
       " '517357553',\n",
       " '2021435753',\n",
       " '1214006960',\n",
       " '1008861493',\n",
       " '2238460219',\n",
       " '3709066919',\n",
       " '2491651409',\n",
       " '516110926',\n",
       " '3927635634',\n",
       " '1437617088',\n",
       " '1803816912',\n",
       " '182290053',\n",
       " '3962251454',\n",
       " '3934266336',\n",
       " '3330927216',\n",
       " '3779883288',\n",
       " '3315282129',\n",
       " '1832146052',\n",
       " '2169945834',\n",
       " '324467789',\n",
       " '2896254370',\n",
       " '2536496919',\n",
       " '3835637004',\n",
       " '3303967764',\n",
       " '2890467561',\n",
       " '3804509987',\n",
       " '973677184',\n",
       " '3971863644',\n",
       " '2265899995',\n",
       " '2332715028',\n",
       " '3227661980',\n",
       " '57783108',\n",
       " '2138239477',\n",
       " '2643058163',\n",
       " '2694023881',\n",
       " '3269497309',\n",
       " '2943972367',\n",
       " '708073241',\n",
       " '3284221169',\n",
       " '3091527231',\n",
       " '511678471',\n",
       " '1810026348',\n",
       " '576776993',\n",
       " '3531604778',\n",
       " '2644266735',\n",
       " '483141559',\n",
       " '1251857185',\n",
       " '4091804141',\n",
       " '3676872343',\n",
       " '806278943',\n",
       " '82923911',\n",
       " '1213367737',\n",
       " '1484078818',\n",
       " '3096870348',\n",
       " '160673392',\n",
       " '1952989987',\n",
       " '374950100',\n",
       " '3486057072',\n",
       " '1323529412',\n",
       " '2650493630',\n",
       " '2789613386',\n",
       " '110310789',\n",
       " '634885878',\n",
       " '1317057097',\n",
       " '403920458',\n",
       " '2566144998',\n",
       " '987701123',\n",
       " '2577093097',\n",
       " '460608021',\n",
       " '785251375',\n",
       " '135706634',\n",
       " '620032149',\n",
       " '1309915074',\n",
       " '3695179498',\n",
       " '792037916',\n",
       " '4201750807',\n",
       " '299446963',\n",
       " '3421026299',\n",
       " '694221975',\n",
       " '1537885461',\n",
       " '2022846287',\n",
       " '379327893',\n",
       " '422699736',\n",
       " '559905447',\n",
       " '2864941156',\n",
       " '2413089165',\n",
       " '2678956041',\n",
       " '2716313754',\n",
       " '2054531858',\n",
       " '2404499203',\n",
       " '2068379568',\n",
       " '1119929505',\n",
       " '2416903887',\n",
       " '3035853030',\n",
       " '1219372694',\n",
       " '98054194',\n",
       " '4245654844',\n",
       " '4011347584',\n",
       " '1006838695',\n",
       " '2162823560',\n",
       " '1555282107',\n",
       " '4007974189',\n",
       " '1539795814',\n",
       " '2488685741',\n",
       " '285396757',\n",
       " '3599572670',\n",
       " '1071963586',\n",
       " '1918945522',\n",
       " '1507405031',\n",
       " '1476956307',\n",
       " '2690867178',\n",
       " '3194014105',\n",
       " '1162467941',\n",
       " '2024760795',\n",
       " '596044827',\n",
       " '3926213876',\n",
       " '3480044787',\n",
       " '547302435',\n",
       " '3775078143',\n",
       " '1319081165',\n",
       " '2604497840',\n",
       " '747578727',\n",
       " '73830292',\n",
       " '934187073',\n",
       " '1987194661',\n",
       " '883614923',\n",
       " '649114603',\n",
       " '1176550521',\n",
       " '2712755708',\n",
       " '3065586006',\n",
       " '662608699',\n",
       " '2350981164',\n",
       " '3391264132',\n",
       " '592689052',\n",
       " '2254352523',\n",
       " '156603823',\n",
       " '3730114567',\n",
       " '2337182196',\n",
       " '4195660981',\n",
       " '2243065045',\n",
       " '1520557068',\n",
       " '3946163681',\n",
       " '2680339394',\n",
       " '2193628344',\n",
       " '2912946138',\n",
       " '2638307735',\n",
       " '3006433212',\n",
       " '1482478167',\n",
       " '1299595690',\n",
       " '968336394',\n",
       " '2271406145',\n",
       " '1493407039',\n",
       " '4040113414',\n",
       " '1507678209',\n",
       " '1141805584',\n",
       " '1280283349',\n",
       " '3935809106',\n",
       " '3841524478',\n",
       " '1223566187',\n",
       " '3251568850',\n",
       " '363577443',\n",
       " '2243396544',\n",
       " '3866909611',\n",
       " '3825327054',\n",
       " '1959680039',\n",
       " '2936934993',\n",
       " '1855764195',\n",
       " '3791989238',\n",
       " '2034510440',\n",
       " '1776705938',\n",
       " '2488849942',\n",
       " '2573722639',\n",
       " '1476755701',\n",
       " '167608261',\n",
       " '3563882371',\n",
       " '4041015401',\n",
       " '1452056386',\n",
       " '2804635189',\n",
       " '47659843',\n",
       " '81458678',\n",
       " '1917038415',\n",
       " '1177603447',\n",
       " '29002074',\n",
       " '2106243741',\n",
       " '3475966810',\n",
       " '481236042',\n",
       " '1432546106',\n",
       " '3937992703',\n",
       " '3943899827',\n",
       " '1607600653',\n",
       " '543735376',\n",
       " '685933857',\n",
       " '865750173',\n",
       " '1123244794',\n",
       " '2805512120',\n",
       " '4058274528',\n",
       " '1906220044',\n",
       " '1201125575',\n",
       " '4088211339',\n",
       " '763615925',\n",
       " '1669357187',\n",
       " '495379217',\n",
       " '2305032569',\n",
       " '1227484684',\n",
       " '489332113',\n",
       " '1756431678',\n",
       " '1066372954',\n",
       " '43826519',\n",
       " '1221271987',\n",
       " '2980760895',\n",
       " '2477144867',\n",
       " '4157365314',\n",
       " '3252326922',\n",
       " '210626346',\n",
       " '2500150280',\n",
       " '3669515588',\n",
       " '2386480530',\n",
       " '1039053975',\n",
       " '1275857085',\n",
       " '1807506815',\n",
       " '2633145288',\n",
       " '2967464230',\n",
       " '1217122759',\n",
       " '2833011810',\n",
       " '220184636',\n",
       " '1711604959',\n",
       " '734292380',\n",
       " '3798379681',\n",
       " '2458053629',\n",
       " '640531312',\n",
       " '2351788775',\n",
       " '3635935632',\n",
       " '3122183291',\n",
       " '2610677742',\n",
       " '611059554',\n",
       " '3082761932',\n",
       " '934944362',\n",
       " '2160680517',\n",
       " '3433923309',\n",
       " '533192042',\n",
       " '1842145373',\n",
       " '521893181',\n",
       " '3843287866',\n",
       " '1344653000',\n",
       " '1467753127',\n",
       " '292529766',\n",
       " '1882369333',\n",
       " '3389539441',\n",
       " '2844491503',\n",
       " '3882784583',\n",
       " '2933561364',\n",
       " '1174496191',\n",
       " '3482266552',\n",
       " '1214698655',\n",
       " '3286878858',\n",
       " '4044018474',\n",
       " '3642118045',\n",
       " '221717938',\n",
       " '2539871585',\n",
       " '2989025224',\n",
       " '1683687851',\n",
       " '3395187066',\n",
       " '640550522',\n",
       " '1793590520',\n",
       " '491263047',\n",
       " '1407394581',\n",
       " '35629376',\n",
       " '2766172404',\n",
       " '3659421361',\n",
       " '4228123262',\n",
       " '3770864710',\n",
       " '3436715440',\n",
       " '2838808644',\n",
       " '1134784132',\n",
       " '427471768',\n",
       " '4165509784',\n",
       " '3236041774',\n",
       " '2875507009',\n",
       " '3858694816',\n",
       " '2726693879',\n",
       " '998215810',\n",
       " '2512840473',\n",
       " '2330978075',\n",
       " '1710009181',\n",
       " '531662584',\n",
       " '1287850161',\n",
       " '1940954160',\n",
       " '2360121322',\n",
       " '793834125',\n",
       " '1120323401',\n",
       " '786776836',\n",
       " '3814621161',\n",
       " '16454810',\n",
       " '4157381568',\n",
       " '1641960627',\n",
       " '3024528036',\n",
       " '3292395061',\n",
       " '1543462230',\n",
       " '2571725299',\n",
       " '4213772349',\n",
       " '2353444142',\n",
       " '1160148526',\n",
       " '4058821927',\n",
       " '581584739',\n",
       " '3456890538',\n",
       " '4168402703',\n",
       " '1138996450',\n",
       " '2065629938',\n",
       " '3981117943',\n",
       " '1016099896',\n",
       " '1931229576',\n",
       " '3874603947',\n",
       " '3734794530',\n",
       " '2217567238',\n",
       " '691831024',\n",
       " '1585175216',\n",
       " '3838037746',\n",
       " '249577815',\n",
       " '3138635490',\n",
       " '2451466347',\n",
       " '1287950172',\n",
       " '2985559658',\n",
       " '2452785645',\n",
       " '1049481453',\n",
       " '22840021',\n",
       " '1805968919',\n",
       " '2018840392',\n",
       " '1697658257',\n",
       " '2864899561',\n",
       " '1729709850',\n",
       " '576889228',\n",
       " '411622998',\n",
       " '4247824186',\n",
       " '3083116980',\n",
       " '1781308359',\n",
       " '1101972092',\n",
       " '358368837',\n",
       " '4133514703',\n",
       " '3961606436',\n",
       " '309131167',\n",
       " '3550832930',\n",
       " '1668335332',\n",
       " '1733597545',\n",
       " '2572315833',\n",
       " '1386311924',\n",
       " '3945099542',\n",
       " '1522287705',\n",
       " '1949308966',\n",
       " '635462786',\n",
       " '1666288434',\n",
       " '3240223983',\n",
       " '2022308068',\n",
       " '1020875748',\n",
       " '2390912815',\n",
       " '3530946278',\n",
       " '554693050',\n",
       " '1859726822',\n",
       " '3464961116',\n",
       " '1910313147',\n",
       " '2795891642',\n",
       " '1072041355',\n",
       " '2621463744',\n",
       " '2128672319',\n",
       " '866032649',\n",
       " '344313409',\n",
       " '2520120463',\n",
       " '1648729660',\n",
       " '3344502842',\n",
       " '3867877244',\n",
       " '3053992683',\n",
       " '2275600529',\n",
       " '221442949',\n",
       " '395811323',\n",
       " '3556981605',\n",
       " '895925498',\n",
       " '971079958',\n",
       " '2209002289',\n",
       " '1783276120',\n",
       " '316066613',\n",
       " '1539256277',\n",
       " '651240040',\n",
       " '905852095',\n",
       " '3275450415',\n",
       " '488389895',\n",
       " '2616577596',\n",
       " '1873358601',\n",
       " '214127647',\n",
       " '3797537201',\n",
       " '466698547',\n",
       " '2557219570',\n",
       " '1981701814',\n",
       " '395305791',\n",
       " '1298546667',\n",
       " '3870800241',\n",
       " '1931818423',\n",
       " '2628219969',\n",
       " '1784363573',\n",
       " '2291885035',\n",
       " '3109949526',\n",
       " '4284267710',\n",
       " '363257522',\n",
       " '48222018',\n",
       " '1577437083',\n",
       " '3645703035',\n",
       " '964184183',\n",
       " '2878125264',\n",
       " '499079668',\n",
       " '292322045',\n",
       " '1186306562',\n",
       " '2434848920',\n",
       " '4176372154',\n",
       " '486871070',\n",
       " '1069845555',\n",
       " '3951036457',\n",
       " '2393365897',\n",
       " '1668862262',\n",
       " '1848901690',\n",
       " '4051263407',\n",
       " '3454909050',\n",
       " '13301498',\n",
       " '1575020018',\n",
       " '4222590338',\n",
       " '3909997753',\n",
       " '1221391751',\n",
       " '3151372447',\n",
       " '4188511767',\n",
       " '1879127286',\n",
       " '3758003912',\n",
       " '2288466976',\n",
       " '3384998777',\n",
       " '3172450732',\n",
       " '2424565945',\n",
       " '1541756008',\n",
       " '2393678699',\n",
       " '2056142684',\n",
       " '527523423',\n",
       " '1754904960',\n",
       " '4067602271',\n",
       " '1060557660',\n",
       " '959300591',\n",
       " '645859586',\n",
       " '1567499133',\n",
       " '2325340243',\n",
       " '1665746866',\n",
       " '1206686094',\n",
       " '4022287072',\n",
       " '2660754061',\n",
       " '4166294065',\n",
       " '779605206',\n",
       " '178408585',\n",
       " '2619163162',\n",
       " '3920980605',\n",
       " '562762742',\n",
       " '1684440449',\n",
       " '2930631258',\n",
       " '1889089758',\n",
       " '2394571811',\n",
       " '61814256',\n",
       " '2007776821',\n",
       " '2153152806',\n",
       " '3861090052',\n",
       " '71092144',\n",
       " '2756550887',\n",
       " '1069507870',\n",
       " '1607711586',\n",
       " '2813573544',\n",
       " '2416484731',\n",
       " '2317630684',\n",
       " '2512917389',\n",
       " '571415268',\n",
       " '2225154987',\n",
       " '3095718598',\n",
       " '1132746796',\n",
       " '2937936158',\n",
       " '3151067532',\n",
       " '1625116475',\n",
       " '66260844',\n",
       " '4122483286',\n",
       " '1053832375',\n",
       " '1941301893',\n",
       " '515567373',\n",
       " '1800702076',\n",
       " '1757163647',\n",
       " '1075375005',\n",
       " '3600455391',\n",
       " '3822987687',\n",
       " '3609055912',\n",
       " '4206471336',\n",
       " '3709640639',\n",
       " '3887899389',\n",
       " '682630586',\n",
       " '2356937947',\n",
       " '1010701404',\n",
       " '700438783',\n",
       " '3175354507',\n",
       " '3393069828',\n",
       " '3519404949',\n",
       " '2937549539',\n",
       " '591781953',\n",
       " '4148656943',\n",
       " '1126868438',\n",
       " '1345896548',\n",
       " '3953805126',\n",
       " '2925400415',\n",
       " '2777195317',\n",
       " '3686871863',\n",
       " '876103013',\n",
       " '3005728385',\n",
       " '3155504635',\n",
       " '3625917937',\n",
       " '3347075701',\n",
       " '3298977709',\n",
       " '1567057770',\n",
       " '3427263623',\n",
       " '3071657222',\n",
       " '4002956902',\n",
       " '4146675310',\n",
       " '2322320168',\n",
       " '3535608264',\n",
       " '3481743878',\n",
       " '4282954307',\n",
       " '2902724458',\n",
       " '3279316025',\n",
       " '3311830643',\n",
       " '3918374668',\n",
       " '609630180',\n",
       " '1350285710',\n",
       " '2532017830',\n",
       " '2590409583',\n",
       " '3388914512',\n",
       " '589386328',\n",
       " '741804596',\n",
       " '614599699',\n",
       " '3042642967',\n",
       " '3026296984',\n",
       " '4060379526',\n",
       " '1094788037',\n",
       " '842198355',\n",
       " '1404395751',\n",
       " '2541238114',\n",
       " '4162769577',\n",
       " '4106927042',\n",
       " '378788595',\n",
       " '1737346733',\n",
       " '1628172447',\n",
       " '160230482',\n",
       " '140576550',\n",
       " '721089780',\n",
       " '3618985332',\n",
       " '3471761709',\n",
       " '2489943153',\n",
       " '1571490313',\n",
       " '3096946503',\n",
       " '3648621560',\n",
       " '2156920475',\n",
       " '4119250454',\n",
       " '2658254174',\n",
       " '4159195102',\n",
       " '1717882536',\n",
       " '2023976924',\n",
       " '1594431230',\n",
       " '1500569811',\n",
       " '96931058',\n",
       " '442080465',\n",
       " '1974832510',\n",
       " '1339643555',\n",
       " '1233124121',\n",
       " '1579613783',\n",
       " '3041705231',\n",
       " '637505307',\n",
       " '4165482530',\n",
       " '2860912043',\n",
       " '3299137750',\n",
       " '3312901615',\n",
       " '2731543010',\n",
       " '4079159663',\n",
       " '1368412107',\n",
       " '3876455884',\n",
       " '1122537977',\n",
       " '491792092',\n",
       " '3968108639',\n",
       " '3764872798',\n",
       " '1191065441',\n",
       " '1452921099',\n",
       " '2069512156',\n",
       " '743802819',\n",
       " '1834677339',\n",
       " '414832767',\n",
       " '691612308',\n",
       " '364700925',\n",
       " '4244826201',\n",
       " '367845178',\n",
       " '2940917694',\n",
       " '460024134',\n",
       " '528810329',\n",
       " '3488552280',\n",
       " '2202079852',\n",
       " '3657701087',\n",
       " '635387882',\n",
       " '2679652649',\n",
       " '4057542584',\n",
       " '4181543522',\n",
       " '1427469971',\n",
       " '2920617215',\n",
       " '4128087249',\n",
       " '1947430492',\n",
       " '72298333',\n",
       " '1040473939',\n",
       " '33930603',\n",
       " '2689941153',\n",
       " '551538117',\n",
       " '1788141082',\n",
       " '3131909049',\n",
       " '338395830',\n",
       " '233871977',\n",
       " '2513652558',\n",
       " '3261632504',\n",
       " '3839562998',\n",
       " '1930913390',\n",
       " '2815174275',\n",
       " '1115249498',\n",
       " '3282478477',\n",
       " '3480781792',\n",
       " '2040340167',\n",
       " '3956887319',\n",
       " '223870698',\n",
       " '4246010516',\n",
       " '1565310892',\n",
       " '1575376083',\n",
       " '2841225823',\n",
       " '3235544076',\n",
       " '3711334312',\n",
       " '322208106',\n",
       " '2244689014',\n",
       " '2041677127',\n",
       " '4051807703',\n",
       " '2713603391',\n",
       " '2417747893',\n",
       " '3188496109',\n",
       " '137002204',\n",
       " '2101691514',\n",
       " '4178291537',\n",
       " '3221545220',\n",
       " '2399025474',\n",
       " '2458429643',\n",
       " '4257951883',\n",
       " '2537288678',\n",
       " '1444113850',\n",
       " '3565456636',\n",
       " '3504868122',\n",
       " '4272342830',\n",
       " '3493543279',\n",
       " '1197154185',\n",
       " '3210947692',\n",
       " '1160667975',\n",
       " '2654323600',\n",
       " '1338460474',\n",
       " '2419536569',\n",
       " '2441936878',\n",
       " '900897870',\n",
       " '326930040',\n",
       " '113021847',\n",
       " '2123040565',\n",
       " '248375618',\n",
       " '2896196906',\n",
       " '4085088124',\n",
       " '1697865048',\n",
       " '2259554717',\n",
       " '4048868881',\n",
       " '3719137321',\n",
       " '1071319145',\n",
       " '1301544506',\n",
       " '1287353407',\n",
       " '1039126403',\n",
       " '2635547119',\n",
       " '2090888096',\n",
       " '33966018',\n",
       " '3296184072',\n",
       " '400629571',\n",
       " '366365683',\n",
       " '2813858112',\n",
       " '3523009435',\n",
       " '3270633490',\n",
       " '3669048335',\n",
       " '1164338332',\n",
       " '2552614841',\n",
       " '1127657981',\n",
       " '1856999246',\n",
       " '2672443109',\n",
       " '1038960564',\n",
       " '2409482937',\n",
       " '1420338074',\n",
       " '3469589500',\n",
       " '2222375586',\n",
       " '23150045',\n",
       " '2238882361',\n",
       " '2964090531',\n",
       " '3554586211',\n",
       " '3834320657',\n",
       " '2544817539',\n",
       " '94142526',\n",
       " '3368369538',\n",
       " '3427391302',\n",
       " '3926920467',\n",
       " '3441266811',\n",
       " '3004312073',\n",
       " '4101515763',\n",
       " '419778061',\n",
       " '1034249941',\n",
       " '355445705',\n",
       " '3325628838',\n",
       " '1952851403',\n",
       " '2891771317',\n",
       " '2993544760',\n",
       " '458389001',\n",
       " '4081921627',\n",
       " '547127090',\n",
       " '2762021126',\n",
       " '1821733300',\n",
       " '1313492534',\n",
       " '2501052021',\n",
       " '2680823346',\n",
       " '555631167',\n",
       " '3668442410',\n",
       " '1844741381',\n",
       " '3773947618',\n",
       " '3317432819',\n",
       " '3883721026',\n",
       " '1610329121',\n",
       " '1154164776',\n",
       " '1561371437',\n",
       " '1853545080',\n",
       " '1939233431',\n",
       " '2915713626',\n",
       " '3970477206',\n",
       " '3787931088',\n",
       " '4162525077',\n",
       " '1919684252',\n",
       " '3939277895',\n",
       " '612098420',\n",
       " '3893362486',\n",
       " '1551265824',\n",
       " '4227630018',\n",
       " '4024328014',\n",
       " '4195841083',\n",
       " '4233914020',\n",
       " '1766663257',\n",
       " '3430986998',\n",
       " '2975408825',\n",
       " '4168411373',\n",
       " '87299174',\n",
       " '396929851',\n",
       " '2282257791',\n",
       " '2063287658',\n",
       " '4095059025',\n",
       " '2348719537',\n",
       " '2984260178',\n",
       " '3102057813',\n",
       " '3812598434',\n",
       " '3052191172',\n",
       " '2823307221',\n",
       " '4246087593',\n",
       " '869928463',\n",
       " '2615377525',\n",
       " '2980440229',\n",
       " '2684781446',\n",
       " '3404441712',\n",
       " '743008535',\n",
       " '1171363794',\n",
       " '3167658465',\n",
       " '1890962723',\n",
       " '1101602207',\n",
       " '3838242688',\n",
       " '677048573',\n",
       " '3685921102',\n",
       " '777634122',\n",
       " '4261865653',\n",
       " '489170488',\n",
       " '2485680197',\n",
       " '1578153876',\n",
       " '1317928829',\n",
       " '2343762978',\n",
       " '2265864872',\n",
       " '1997928281',\n",
       " '1905298796',\n",
       " '265682801',\n",
       " '1661089307',\n",
       " '3257773536',\n",
       " '4181821860',\n",
       " '2849010050',\n",
       " '4181452333',\n",
       " '2467706552',\n",
       " '4207448575',\n",
       " '1908507314',\n",
       " '1116289197',\n",
       " '1320099877',\n",
       " '314484928',\n",
       " '4042546595',\n",
       " '1445882902',\n",
       " '1195601618',\n",
       " '2622502489',\n",
       " '1000066358',\n",
       " '2223714757',\n",
       " '37106093',\n",
       " '2278416805',\n",
       " '3368619983',\n",
       " '2275313265',\n",
       " '4000106370',\n",
       " '909725785',\n",
       " '1671510792',\n",
       " '3577629547',\n",
       " '218125888',\n",
       " '306153925',\n",
       " '194257626',\n",
       " '441120644',\n",
       " '2651959030',\n",
       " '1023717643',\n",
       " '2962725194',\n",
       " '2589452714',\n",
       " '1474879368',\n",
       " '3850128249',\n",
       " '110342379',\n",
       " '3631889944',\n",
       " '3076344276',\n",
       " '4159956578',\n",
       " '197344023',\n",
       " '394596900',\n",
       " '424866781',\n",
       " '1838447403',\n",
       " '413881487',\n",
       " '648323757',\n",
       " '986039272',\n",
       " '2491957982',\n",
       " '1707278925',\n",
       " '2504328739',\n",
       " '2648736219',\n",
       " '2556133275',\n",
       " '699420462',\n",
       " '1531339765',\n",
       " '1549085270',\n",
       " '2675088061',\n",
       " '1342752171',\n",
       " '3170052426',\n",
       " '237595480',\n",
       " '382550204',\n",
       " '802688704',\n",
       " '2842187594',\n",
       " '2958453070',\n",
       " '187910813',\n",
       " '2485670452',\n",
       " '2712018445',\n",
       " '2205166542',\n",
       " '3036141956',\n",
       " '1890318514',\n",
       " '567536219',\n",
       " '2873615520',\n",
       " '222319155',\n",
       " '1290399197',\n",
       " '1872064755',\n",
       " '41934198',\n",
       " '1131940169',\n",
       " '545289514',\n",
       " '1815238419',\n",
       " '443931185',\n",
       " '1019226310',\n",
       " '75001773',\n",
       " '354974889',\n",
       " '3271072939',\n",
       " '3500240032',\n",
       " '4141924620',\n",
       " '3063570853',\n",
       " '2449767852',\n",
       " '1539932789',\n",
       " '156584666',\n",
       " '2107308395',\n",
       " '203050907',\n",
       " '1166204486',\n",
       " '1157924193',\n",
       " '3554343061',\n",
       " '1781227779',\n",
       " '3803199563',\n",
       " '2238790970',\n",
       " '2403055502',\n",
       " '2080715583',\n",
       " '3348106292',\n",
       " '1011223331',\n",
       " '1735204308',\n",
       " '2764881224',\n",
       " '4062975904',\n",
       " '4046490355',\n",
       " '1328697582',\n",
       " '1541564886',\n",
       " '887085722',\n",
       " '2378571713',\n",
       " '3244428383',\n",
       " '547476091',\n",
       " '4109397627',\n",
       " '4293103086',\n",
       " '2070073073',\n",
       " '2849111044',\n",
       " '898118729',\n",
       " '1109682681',\n",
       " '1737429301',\n",
       " '2501280523',\n",
       " '639409951',\n",
       " '3117046697',\n",
       " '1325052851',\n",
       " '431015679',\n",
       " '1985852583',\n",
       " '521412534',\n",
       " '176349030',\n",
       " '2436252940',\n",
       " '30355949',\n",
       " '670504249',\n",
       " '411205694',\n",
       " '2824647204',\n",
       " '2328481418',\n",
       " '3841682652',\n",
       " '3781956022',\n",
       " '2493952533',\n",
       " '1181399405',\n",
       " '1602963012',\n",
       " '283032695',\n",
       " '3593927263',\n",
       " '2584536356',\n",
       " '1747471686',\n",
       " '730373215',\n",
       " '2275330810',\n",
       " '1980915793',\n",
       " '2700330302',\n",
       " '3663573906',\n",
       " '3104132371',\n",
       " '2657081799',\n",
       " '3211659078',\n",
       " '4115365036',\n",
       " '3614158257',\n",
       " '3365642090',\n",
       " '738525400',\n",
       " '2202271093',\n",
       " '749863583',\n",
       " '2193664477',\n",
       " '2396187234',\n",
       " '3715196259',\n",
       " '1890732196',\n",
       " '2467063943',\n",
       " '2957525159',\n",
       " '3548820422',\n",
       " '397493741',\n",
       " '2681199273',\n",
       " '1701323236',\n",
       " '3826739942',\n",
       " '3326031604',\n",
       " '3818890017',\n",
       " '882525479',\n",
       " '2490592488',\n",
       " '3166414361',\n",
       " '167200370',\n",
       " '3647725503',\n",
       " '4159459029',\n",
       " '3865016311',\n",
       " '4197193550',\n",
       " '681315287',\n",
       " '2098552598',\n",
       " ...}"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "uniqueUsers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "number of uniqueUsers: 3391\n",
      "number of uniqueEvents: 13418\n"
     ]
    }
   ],
   "source": [
    "n_uniqueUsers = len(uniqueUsers)\n",
    "n_uniqueEvents = len(uniqueEvents)\n",
    "print(\"number of uniqueUsers: %d\" % n_uniqueUsers)\n",
    "print(\"number of uniqueEvents: %d\" % n_uniqueEvents)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "userEventScores = ss.dok_matrix((n_uniqueUsers,n_uniqueEvents))\n",
    "userIndex = dict()\n",
    "eventIndex = dict()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "for i, u in enumerate(uniqueUsers):\n",
    "    userIndex[u] = i\n",
    "for i, e in enumerate(uniqueEvents):\n",
    "    eventIndex[e] = i"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'3830003912': 0,\n",
       " '411244492': 1,\n",
       " '3948658168': 2,\n",
       " '4089322861': 3,\n",
       " '3773489407': 4,\n",
       " '4172170403': 5,\n",
       " '968373357': 6,\n",
       " '3479915003': 7,\n",
       " '3506658662': 8,\n",
       " '1093670500': 9,\n",
       " '2039358442': 10,\n",
       " '3520307709': 11,\n",
       " '3899671924': 12,\n",
       " '900991530': 13,\n",
       " '3698076969': 14,\n",
       " '591904611': 15,\n",
       " '1701670121': 16,\n",
       " '945248517': 17,\n",
       " '3305669901': 18,\n",
       " '4250274626': 19,\n",
       " '450183377': 20,\n",
       " '1330332438': 21,\n",
       " '4210780884': 22,\n",
       " '2269849993': 23,\n",
       " '799334346': 24,\n",
       " '1625043970': 25,\n",
       " '4065675893': 26,\n",
       " '858707451': 27,\n",
       " '3232656056': 28,\n",
       " '2002132690': 29,\n",
       " '3636792221': 30,\n",
       " '3382116221': 31,\n",
       " '2259759203': 32,\n",
       " '2516777172': 33,\n",
       " '1922434523': 34,\n",
       " '738950797': 35,\n",
       " '1486124986': 36,\n",
       " '2210350678': 37,\n",
       " '94390648': 38,\n",
       " '3732509776': 39,\n",
       " '585897410': 40,\n",
       " '3017306176': 41,\n",
       " '1940061840': 42,\n",
       " '3340777098': 43,\n",
       " '3528426861': 44,\n",
       " '4127849475': 45,\n",
       " '1722911749': 46,\n",
       " '1866219535': 47,\n",
       " '1466704967': 48,\n",
       " '2056684630': 49,\n",
       " '3435033871': 50,\n",
       " '4242816413': 51,\n",
       " '3417455063': 52,\n",
       " '1529892177': 53,\n",
       " '3192664309': 54,\n",
       " '578876481': 55,\n",
       " '662043969': 56,\n",
       " '2540540072': 57,\n",
       " '2279347311': 58,\n",
       " '3989742514': 59,\n",
       " '1011767003': 60,\n",
       " '1033209626': 61,\n",
       " '1570416070': 62,\n",
       " '1615404222': 63,\n",
       " '101008559': 64,\n",
       " '4154028951': 65,\n",
       " '1270821753': 66,\n",
       " '2056583312': 67,\n",
       " '2484041898': 68,\n",
       " '2206508128': 69,\n",
       " '3044687724': 70,\n",
       " '3566604706': 71,\n",
       " '835265617': 72,\n",
       " '3504788955': 73,\n",
       " '2593474804': 74,\n",
       " '2590934028': 75,\n",
       " '237764772': 76,\n",
       " '670599422': 77,\n",
       " '3017074183': 78,\n",
       " '4013025273': 79,\n",
       " '2376501244': 80,\n",
       " '1600570366': 81,\n",
       " '1134231092': 82,\n",
       " '2359520876': 83,\n",
       " '1644685632': 84,\n",
       " '2196514887': 85,\n",
       " '2742796684': 86,\n",
       " '1253059865': 87,\n",
       " '3417632652': 88,\n",
       " '2044297478': 89,\n",
       " '1466022381': 90,\n",
       " '153565237': 91,\n",
       " '2613386532': 92,\n",
       " '4204629344': 93,\n",
       " '887883465': 94,\n",
       " '1372188915': 95,\n",
       " '3321517547': 96,\n",
       " '3697176442': 97,\n",
       " '2798516620': 98,\n",
       " '3487833744': 99,\n",
       " '1152772826': 100,\n",
       " '3406775761': 101,\n",
       " '617227257': 102,\n",
       " '3036178663': 103,\n",
       " '1517730411': 104,\n",
       " '939509575': 105,\n",
       " '813746591': 106,\n",
       " '2622371373': 107,\n",
       " '2274620725': 108,\n",
       " '2607590492': 109,\n",
       " '3680303526': 110,\n",
       " '3759330615': 111,\n",
       " '2289214808': 112,\n",
       " '2965867805': 113,\n",
       " '1492218856': 114,\n",
       " '1609864127': 115,\n",
       " '913747949': 116,\n",
       " '2178346412': 117,\n",
       " '2698678033': 118,\n",
       " '1031615077': 119,\n",
       " '3376956416': 120,\n",
       " '580944656': 121,\n",
       " '2286605851': 122,\n",
       " '3793452317': 123,\n",
       " '2224313777': 124,\n",
       " '3523553728': 125,\n",
       " '3348456289': 126,\n",
       " '2846542700': 127,\n",
       " '2714876429': 128,\n",
       " '2735190761': 129,\n",
       " '771048344': 130,\n",
       " '38211426': 131,\n",
       " '3048315473': 132,\n",
       " '2174082261': 133,\n",
       " '1634994103': 134,\n",
       " '4198564536': 135,\n",
       " '4125204455': 136,\n",
       " '3673014182': 137,\n",
       " '1896349766': 138,\n",
       " '2828912555': 139,\n",
       " '123333167': 140,\n",
       " '4027073137': 141,\n",
       " '1517488130': 142,\n",
       " '1805425126': 143,\n",
       " '3667338776': 144,\n",
       " '414842182': 145,\n",
       " '2379950964': 146,\n",
       " '3282344594': 147,\n",
       " '1578063348': 148,\n",
       " '3756572732': 149,\n",
       " '1900974580': 150,\n",
       " '4224104772': 151,\n",
       " '2361758181': 152,\n",
       " '2339593321': 153,\n",
       " '210121672': 154,\n",
       " '1862523963': 155,\n",
       " '1668498113': 156,\n",
       " '2051799233': 157,\n",
       " '2129255857': 158,\n",
       " '2232765899': 159,\n",
       " '1488264230': 160,\n",
       " '1760975014': 161,\n",
       " '2269110763': 162,\n",
       " '1184041113': 163,\n",
       " '3462834913': 164,\n",
       " '2628680570': 165,\n",
       " '3769856229': 166,\n",
       " '2642707561': 167,\n",
       " '832412932': 168,\n",
       " '2572673665': 169,\n",
       " '983806490': 170,\n",
       " '127649684': 171,\n",
       " '3511745359': 172,\n",
       " '3311992185': 173,\n",
       " '1141674672': 174,\n",
       " '191661856': 175,\n",
       " '3582524764': 176,\n",
       " '1733366362': 177,\n",
       " '2718272622': 178,\n",
       " '1345755464': 179,\n",
       " '1226009206': 180,\n",
       " '1679182061': 181,\n",
       " '2635162962': 182,\n",
       " '3212746272': 183,\n",
       " '901144614': 184,\n",
       " '777926482': 185,\n",
       " '562225265': 186,\n",
       " '2043455253': 187,\n",
       " '2444401672': 188,\n",
       " '1556254993': 189,\n",
       " '171025395': 190,\n",
       " '3701432790': 191,\n",
       " '3732064146': 192,\n",
       " '2127623176': 193,\n",
       " '1639958590': 194,\n",
       " '1506510838': 195,\n",
       " '1091130052': 196,\n",
       " '696974056': 197,\n",
       " '2700038507': 198,\n",
       " '3863201568': 199,\n",
       " '1287319410': 200,\n",
       " '1684746528': 201,\n",
       " '3967790299': 202,\n",
       " '2693083714': 203,\n",
       " '3867931782': 204,\n",
       " '1598436829': 205,\n",
       " '1977805725': 206,\n",
       " '3942998498': 207,\n",
       " '3079146363': 208,\n",
       " '4099353109': 209,\n",
       " '4040837426': 210,\n",
       " '391871409': 211,\n",
       " '1077498346': 212,\n",
       " '866329141': 213,\n",
       " '4284647357': 214,\n",
       " '758156246': 215,\n",
       " '3001163794': 216,\n",
       " '3948784617': 217,\n",
       " '3119717504': 218,\n",
       " '4000101630': 219,\n",
       " '1829278132': 220,\n",
       " '2166881970': 221,\n",
       " '852362805': 222,\n",
       " '1935879458': 223,\n",
       " '3312315763': 224,\n",
       " '2861164727': 225,\n",
       " '1303026980': 226,\n",
       " '2315973008': 227,\n",
       " '2048271447': 228,\n",
       " '2608543989': 229,\n",
       " '2732810444': 230,\n",
       " '1136599794': 231,\n",
       " '2850509209': 232,\n",
       " '929383818': 233,\n",
       " '3538439402': 234,\n",
       " '3030445347': 235,\n",
       " '463131402': 236,\n",
       " '2653923514': 237,\n",
       " '2809906088': 238,\n",
       " '1329920443': 239,\n",
       " '2806623786': 240,\n",
       " '3515520150': 241,\n",
       " '3008741424': 242,\n",
       " '223675975': 243,\n",
       " '2880970123': 244,\n",
       " '3677554347': 245,\n",
       " '1685190005': 246,\n",
       " '1857491294': 247,\n",
       " '2748538029': 248,\n",
       " '414811541': 249,\n",
       " '590488063': 250,\n",
       " '894141796': 251,\n",
       " '2380117374': 252,\n",
       " '2216215956': 253,\n",
       " '2252497386': 254,\n",
       " '145185489': 255,\n",
       " '2648833412': 256,\n",
       " '3583332424': 257,\n",
       " '56286280': 258,\n",
       " '3657419629': 259,\n",
       " '1076499062': 260,\n",
       " '2952934281': 261,\n",
       " '2892367012': 262,\n",
       " '2303466552': 263,\n",
       " '3712322311': 264,\n",
       " '4244463632': 265,\n",
       " '3582418533': 266,\n",
       " '3174177804': 267,\n",
       " '829650247': 268,\n",
       " '2808705599': 269,\n",
       " '4163453351': 270,\n",
       " '799065233': 271,\n",
       " '2979448805': 272,\n",
       " '388489337': 273,\n",
       " '1415883658': 274,\n",
       " '1386545389': 275,\n",
       " '645163767': 276,\n",
       " '411731753': 277,\n",
       " '3856018417': 278,\n",
       " '3051804335': 279,\n",
       " '3284911153': 280,\n",
       " '3743521539': 281,\n",
       " '3289683998': 282,\n",
       " '1579557996': 283,\n",
       " '859015855': 284,\n",
       " '1891078660': 285,\n",
       " '30179042': 286,\n",
       " '1798929494': 287,\n",
       " '2475876989': 288,\n",
       " '1182610223': 289,\n",
       " '1382852410': 290,\n",
       " '466258678': 291,\n",
       " '363024307': 292,\n",
       " '1672363370': 293,\n",
       " '2653549574': 294,\n",
       " '322567970': 295,\n",
       " '3368006282': 296,\n",
       " '3366499153': 297,\n",
       " '3957104249': 298,\n",
       " '3708910341': 299,\n",
       " '2392374410': 300,\n",
       " '3782162078': 301,\n",
       " '3874363313': 302,\n",
       " '750584397': 303,\n",
       " '2422810156': 304,\n",
       " '3802316845': 305,\n",
       " '2518909170': 306,\n",
       " '3807386691': 307,\n",
       " '1615468226': 308,\n",
       " '2114066448': 309,\n",
       " '3022508755': 310,\n",
       " '392143091': 311,\n",
       " '439311946': 312,\n",
       " '3789409122': 313,\n",
       " '367679822': 314,\n",
       " '1516164055': 315,\n",
       " '4280025323': 316,\n",
       " '3825878532': 317,\n",
       " '1710669663': 318,\n",
       " '2029812325': 319,\n",
       " '2646392315': 320,\n",
       " '3732721577': 321,\n",
       " '3931717290': 322,\n",
       " '3847927617': 323,\n",
       " '441814828': 324,\n",
       " '1147324673': 325,\n",
       " '2597085367': 326,\n",
       " '3013514096': 327,\n",
       " '3738288081': 328,\n",
       " '4266815563': 329,\n",
       " '2814323926': 330,\n",
       " '3388395910': 331,\n",
       " '2178551581': 332,\n",
       " '530788794': 333,\n",
       " '327075228': 334,\n",
       " '518815654': 335,\n",
       " '1243097755': 336,\n",
       " '1773166853': 337,\n",
       " '2138363616': 338,\n",
       " '4245127010': 339,\n",
       " '2585228502': 340,\n",
       " '3768680031': 341,\n",
       " '2378521366': 342,\n",
       " '999037301': 343,\n",
       " '3692336066': 344,\n",
       " '3002800200': 345,\n",
       " '2915423024': 346,\n",
       " '2385047306': 347,\n",
       " '3943649656': 348,\n",
       " '3581079888': 349,\n",
       " '3974066619': 350,\n",
       " '2259674237': 351,\n",
       " '2317641938': 352,\n",
       " '1826785122': 353,\n",
       " '4219250662': 354,\n",
       " '4101475674': 355,\n",
       " '1397225485': 356,\n",
       " '3947437799': 357,\n",
       " '99279011': 358,\n",
       " '1248215207': 359,\n",
       " '2752772467': 360,\n",
       " '1910411667': 361,\n",
       " '2384544175': 362,\n",
       " '1536819364': 363,\n",
       " '3156836239': 364,\n",
       " '2088291825': 365,\n",
       " '1074855174': 366,\n",
       " '741913828': 367,\n",
       " '708004717': 368,\n",
       " '3832910670': 369,\n",
       " '2808562851': 370,\n",
       " '4119475665': 371,\n",
       " '235695034': 372,\n",
       " '762779146': 373,\n",
       " '1828726073': 374,\n",
       " '3319506135': 375,\n",
       " '1037264024': 376,\n",
       " '1671772898': 377,\n",
       " '2384973677': 378,\n",
       " '2666358956': 379,\n",
       " '1237176319': 380,\n",
       " '1444394097': 381,\n",
       " '3417170518': 382,\n",
       " '2577118609': 383,\n",
       " '253589568': 384,\n",
       " '392819357': 385,\n",
       " '2745787469': 386,\n",
       " '1179474743': 387,\n",
       " '2979795424': 388,\n",
       " '3221950950': 389,\n",
       " '756677655': 390,\n",
       " '992455200': 391,\n",
       " '1174920776': 392,\n",
       " '1602799810': 393,\n",
       " '116335087': 394,\n",
       " '3653306306': 395,\n",
       " '1379671569': 396,\n",
       " '787628032': 397,\n",
       " '3244133531': 398,\n",
       " '2344431772': 399,\n",
       " '1721503828': 400,\n",
       " '107443528': 401,\n",
       " '1703679230': 402,\n",
       " '3943014604': 403,\n",
       " '719337372': 404,\n",
       " '4194031651': 405,\n",
       " '3729155908': 406,\n",
       " '19652138': 407,\n",
       " '788716103': 408,\n",
       " '1454534917': 409,\n",
       " '4207915079': 410,\n",
       " '3481660815': 411,\n",
       " '1744785223': 412,\n",
       " '2363524424': 413,\n",
       " '1187086028': 414,\n",
       " '1742345117': 415,\n",
       " '2902086072': 416,\n",
       " '422926531': 417,\n",
       " '2355910668': 418,\n",
       " '274234888': 419,\n",
       " '2215176482': 420,\n",
       " '1535025408': 421,\n",
       " '2554291574': 422,\n",
       " '588843412': 423,\n",
       " '2627346430': 424,\n",
       " '1922937308': 425,\n",
       " '2789627652': 426,\n",
       " '3321926072': 427,\n",
       " '3843341515': 428,\n",
       " '3344118120': 429,\n",
       " '1879190850': 430,\n",
       " '1363619788': 431,\n",
       " '3454922346': 432,\n",
       " '2337799990': 433,\n",
       " '1050251873': 434,\n",
       " '3764710330': 435,\n",
       " '322709533': 436,\n",
       " '2131729510': 437,\n",
       " '327009161': 438,\n",
       " '2762265640': 439,\n",
       " '220986721': 440,\n",
       " '3942861851': 441,\n",
       " '1370522761': 442,\n",
       " '3512357259': 443,\n",
       " '2463233266': 444,\n",
       " '1895424743': 445,\n",
       " '4035812423': 446,\n",
       " '2599906667': 447,\n",
       " '2479545611': 448,\n",
       " '2299728495': 449,\n",
       " '899234866': 450,\n",
       " '2826099971': 451,\n",
       " '97210112': 452,\n",
       " '3830485621': 453,\n",
       " '2938206150': 454,\n",
       " '2553820588': 455,\n",
       " '3126587697': 456,\n",
       " '154173769': 457,\n",
       " '3803058898': 458,\n",
       " '1922203779': 459,\n",
       " '3786601726': 460,\n",
       " '3907154058': 461,\n",
       " '3221725438': 462,\n",
       " '2572621038': 463,\n",
       " '3202696613': 464,\n",
       " '3991693053': 465,\n",
       " '3126297081': 466,\n",
       " '1838843061': 467,\n",
       " '2527390511': 468,\n",
       " '219854506': 469,\n",
       " '3133239997': 470,\n",
       " '1974247761': 471,\n",
       " '590427279': 472,\n",
       " '278426484': 473,\n",
       " '817091493': 474,\n",
       " '1383850843': 475,\n",
       " '398208897': 476,\n",
       " '806275357': 477,\n",
       " '2825851375': 478,\n",
       " '1368421884': 479,\n",
       " '3840231238': 480,\n",
       " '2914054397': 481,\n",
       " '970593998': 482,\n",
       " '714156115': 483,\n",
       " '45273014': 484,\n",
       " '858638783': 485,\n",
       " '1784859939': 486,\n",
       " '1482977591': 487,\n",
       " '4161762683': 488,\n",
       " '4267908091': 489,\n",
       " '1395960049': 490,\n",
       " '3288255289': 491,\n",
       " '3120842736': 492,\n",
       " '424532519': 493,\n",
       " '784366933': 494,\n",
       " '2517616201': 495,\n",
       " '1441681484': 496,\n",
       " '2393885244': 497,\n",
       " '495865264': 498,\n",
       " '2566518154': 499,\n",
       " '1600524252': 500,\n",
       " '3572977792': 501,\n",
       " '1883639561': 502,\n",
       " '409259074': 503,\n",
       " '3895404984': 504,\n",
       " '2586730902': 505,\n",
       " '2837476507': 506,\n",
       " '1833759794': 507,\n",
       " '2254372858': 508,\n",
       " '649960767': 509,\n",
       " '3530385333': 510,\n",
       " '4114981695': 511,\n",
       " '1824198418': 512,\n",
       " '1360334065': 513,\n",
       " '2830173169': 514,\n",
       " '3326390656': 515,\n",
       " '2696649330': 516,\n",
       " '697614185': 517,\n",
       " '615258122': 518,\n",
       " '2630505719': 519,\n",
       " '1867718138': 520,\n",
       " '2327229116': 521,\n",
       " '2190369261': 522,\n",
       " '3222758405': 523,\n",
       " '2585323353': 524,\n",
       " '3954432137': 525,\n",
       " '2797343771': 526,\n",
       " '3382162822': 527,\n",
       " '589729782': 528,\n",
       " '110436673': 529,\n",
       " '2235632935': 530,\n",
       " '1963354961': 531,\n",
       " '3149756569': 532,\n",
       " '1241270051': 533,\n",
       " '2129718710': 534,\n",
       " '1038016517': 535,\n",
       " '2321729704': 536,\n",
       " '2377812861': 537,\n",
       " '66357203': 538,\n",
       " '2498438372': 539,\n",
       " '1311175038': 540,\n",
       " '3560570011': 541,\n",
       " '1819837770': 542,\n",
       " '2368889606': 543,\n",
       " '2050237599': 544,\n",
       " '1988257084': 545,\n",
       " '997929928': 546,\n",
       " '2412032092': 547,\n",
       " '415360329': 548,\n",
       " '4273848145': 549,\n",
       " '3017798619': 550,\n",
       " '1463875601': 551,\n",
       " '1222519532': 552,\n",
       " '688431737': 553,\n",
       " '774093053': 554,\n",
       " '2027514460': 555,\n",
       " '2587945918': 556,\n",
       " '209332472': 557,\n",
       " '3084168587': 558,\n",
       " '3722349660': 559,\n",
       " '4191185830': 560,\n",
       " '1827572703': 561,\n",
       " '1813646982': 562,\n",
       " '610221734': 563,\n",
       " '3216718101': 564,\n",
       " '3313795740': 565,\n",
       " '3336783567': 566,\n",
       " '301084021': 567,\n",
       " '1363545588': 568,\n",
       " '1116009964': 569,\n",
       " '162437481': 570,\n",
       " '70239777': 571,\n",
       " '3436797348': 572,\n",
       " '1346475100': 573,\n",
       " '4106186736': 574,\n",
       " '3920148761': 575,\n",
       " '2965640468': 576,\n",
       " '979918733': 577,\n",
       " '3811881163': 578,\n",
       " '1367385701': 579,\n",
       " '2557676844': 580,\n",
       " '2052212736': 581,\n",
       " '1095401609': 582,\n",
       " '2520708953': 583,\n",
       " '2363351901': 584,\n",
       " '827158470': 585,\n",
       " '3364485916': 586,\n",
       " '3095347558': 587,\n",
       " '1538209487': 588,\n",
       " '1762521462': 589,\n",
       " '2873343645': 590,\n",
       " '1127671037': 591,\n",
       " '528216257': 592,\n",
       " '2167075374': 593,\n",
       " '3541811987': 594,\n",
       " '2126750158': 595,\n",
       " '2368882162': 596,\n",
       " '2985774237': 597,\n",
       " '3784642395': 598,\n",
       " '3915373411': 599,\n",
       " '3311382169': 600,\n",
       " '1753430045': 601,\n",
       " '3071822251': 602,\n",
       " '1566969892': 603,\n",
       " '3416696354': 604,\n",
       " '2484012499': 605,\n",
       " '2589917271': 606,\n",
       " '1844176380': 607,\n",
       " '2340895720': 608,\n",
       " '1652327247': 609,\n",
       " '2528682460': 610,\n",
       " '1421433916': 611,\n",
       " '1576479513': 612,\n",
       " '1080261006': 613,\n",
       " '2951460111': 614,\n",
       " '4146680584': 615,\n",
       " '3008504566': 616,\n",
       " '3760762503': 617,\n",
       " '3113660150': 618,\n",
       " '1918177304': 619,\n",
       " '3889821387': 620,\n",
       " '3198275968': 621,\n",
       " '615678881': 622,\n",
       " '858726804': 623,\n",
       " '516701061': 624,\n",
       " '2505123910': 625,\n",
       " '1313195291': 626,\n",
       " '3339637743': 627,\n",
       " '3400642235': 628,\n",
       " '716205857': 629,\n",
       " '2084337326': 630,\n",
       " '1057272870': 631,\n",
       " '3272728211': 632,\n",
       " '3267801312': 633,\n",
       " '956438727': 634,\n",
       " '1893629654': 635,\n",
       " '1007362152': 636,\n",
       " '2710165417': 637,\n",
       " '1044974227': 638,\n",
       " '3919221338': 639,\n",
       " '2234592975': 640,\n",
       " '804483110': 641,\n",
       " '2081217514': 642,\n",
       " '1665697394': 643,\n",
       " '2481714628': 644,\n",
       " '1425625542': 645,\n",
       " '2916377597': 646,\n",
       " '2176526451': 647,\n",
       " '1259109743': 648,\n",
       " '2070392690': 649,\n",
       " '601922837': 650,\n",
       " '1253368065': 651,\n",
       " '196924436': 652,\n",
       " '197942693': 653,\n",
       " '489018943': 654,\n",
       " '3425994462': 655,\n",
       " '615488222': 656,\n",
       " '2140447500': 657,\n",
       " '1428612515': 658,\n",
       " '3167757146': 659,\n",
       " '1561841388': 660,\n",
       " '3084829721': 661,\n",
       " '2796416513': 662,\n",
       " '2722304538': 663,\n",
       " '4025024212': 664,\n",
       " '290711008': 665,\n",
       " '4005039699': 666,\n",
       " '1807884467': 667,\n",
       " '1036837546': 668,\n",
       " '1557343462': 669,\n",
       " '1669367540': 670,\n",
       " '1204240464': 671,\n",
       " '3921014619': 672,\n",
       " '1867689034': 673,\n",
       " '2980765180': 674,\n",
       " '3723741723': 675,\n",
       " '3398247231': 676,\n",
       " '1391233886': 677,\n",
       " '714391510': 678,\n",
       " '2411120646': 679,\n",
       " '3562097691': 680,\n",
       " '3483869180': 681,\n",
       " '1689486051': 682,\n",
       " '479542123': 683,\n",
       " '432884667': 684,\n",
       " '1953210268': 685,\n",
       " '2715282469': 686,\n",
       " '1700396522': 687,\n",
       " '2357205252': 688,\n",
       " '3338313474': 689,\n",
       " '3784772051': 690,\n",
       " '2773204108': 691,\n",
       " '268816201': 692,\n",
       " '3312755383': 693,\n",
       " '318809922': 694,\n",
       " '3197825109': 695,\n",
       " '3955743405': 696,\n",
       " '3076799165': 697,\n",
       " '1397490059': 698,\n",
       " '1399415999': 699,\n",
       " '628034280': 700,\n",
       " '1218522841': 701,\n",
       " '1218703283': 702,\n",
       " '3643219070': 703,\n",
       " '427097190': 704,\n",
       " '2198899241': 705,\n",
       " '1945008302': 706,\n",
       " '2023524125': 707,\n",
       " '510687100': 708,\n",
       " '2816622892': 709,\n",
       " '3266931065': 710,\n",
       " '1903272028': 711,\n",
       " '1977103360': 712,\n",
       " '2691215697': 713,\n",
       " '3036141504': 714,\n",
       " '3045187509': 715,\n",
       " '3325146249': 716,\n",
       " '1660590445': 717,\n",
       " '3359524298': 718,\n",
       " '3314397440': 719,\n",
       " '4240012169': 720,\n",
       " '3673627695': 721,\n",
       " '1468625690': 722,\n",
       " '2064060869': 723,\n",
       " '153997026': 724,\n",
       " '1889248965': 725,\n",
       " '790991039': 726,\n",
       " '2471948628': 727,\n",
       " '4099858050': 728,\n",
       " '4097011060': 729,\n",
       " '2169511921': 730,\n",
       " '2643833505': 731,\n",
       " '811652961': 732,\n",
       " '1951437492': 733,\n",
       " '3494504561': 734,\n",
       " '1627365362': 735,\n",
       " '2229290530': 736,\n",
       " '2320431814': 737,\n",
       " '1345381188': 738,\n",
       " '1238456614': 739,\n",
       " '2724372163': 740,\n",
       " '3125637601': 741,\n",
       " '2896575744': 742,\n",
       " '2639713154': 743,\n",
       " '3602746704': 744,\n",
       " '382018152': 745,\n",
       " '3305490944': 746,\n",
       " '2120812238': 747,\n",
       " '2504949294': 748,\n",
       " '181219102': 749,\n",
       " '1218344255': 750,\n",
       " '812245858': 751,\n",
       " '2882404450': 752,\n",
       " '2758523549': 753,\n",
       " '3764379733': 754,\n",
       " '3201936554': 755,\n",
       " '3968521389': 756,\n",
       " '802414638': 757,\n",
       " '175933138': 758,\n",
       " '104397174': 759,\n",
       " '2266549530': 760,\n",
       " '1647257656': 761,\n",
       " '2374000439': 762,\n",
       " '3466523662': 763,\n",
       " '4270106183': 764,\n",
       " '1934335136': 765,\n",
       " '956258196': 766,\n",
       " '1985822680': 767,\n",
       " '2326070806': 768,\n",
       " '1100226557': 769,\n",
       " '2490233992': 770,\n",
       " '2311007113': 771,\n",
       " '2604742516': 772,\n",
       " '2247712885': 773,\n",
       " '159721752': 774,\n",
       " '441988435': 775,\n",
       " '3534825954': 776,\n",
       " '268669105': 777,\n",
       " '803416244': 778,\n",
       " '2255036161': 779,\n",
       " '3309576207': 780,\n",
       " '1693024677': 781,\n",
       " '3877083150': 782,\n",
       " '3612493798': 783,\n",
       " '2049853077': 784,\n",
       " '2086300822': 785,\n",
       " '1849180954': 786,\n",
       " '3526449172': 787,\n",
       " '3709849423': 788,\n",
       " '2723679200': 789,\n",
       " '3231605698': 790,\n",
       " '1680138': 791,\n",
       " '2528580351': 792,\n",
       " '1977909542': 793,\n",
       " '3515598845': 794,\n",
       " '4140301246': 795,\n",
       " '3589430405': 796,\n",
       " '3702762659': 797,\n",
       " '3039059830': 798,\n",
       " '1411410860': 799,\n",
       " '2665105550': 800,\n",
       " '2015759069': 801,\n",
       " '2382680725': 802,\n",
       " '867154832': 803,\n",
       " '3465367492': 804,\n",
       " '1159681214': 805,\n",
       " '3873935598': 806,\n",
       " '3527259407': 807,\n",
       " '754494201': 808,\n",
       " '2119976630': 809,\n",
       " '782683695': 810,\n",
       " '1209358269': 811,\n",
       " '2764949662': 812,\n",
       " '1619381515': 813,\n",
       " '270532321': 814,\n",
       " '3996685669': 815,\n",
       " '2955785263': 816,\n",
       " '3601943023': 817,\n",
       " '2249264436': 818,\n",
       " '1973397903': 819,\n",
       " '3664010858': 820,\n",
       " '48571141': 821,\n",
       " '2454443883': 822,\n",
       " '4078218285': 823,\n",
       " '3193385743': 824,\n",
       " '2943640347': 825,\n",
       " '2473947326': 826,\n",
       " '129024729': 827,\n",
       " '752522970': 828,\n",
       " '2915662989': 829,\n",
       " '3206828033': 830,\n",
       " '2956336268': 831,\n",
       " '1654224995': 832,\n",
       " '621556981': 833,\n",
       " '3063189490': 834,\n",
       " '1571199843': 835,\n",
       " '1329434390': 836,\n",
       " '3668324750': 837,\n",
       " '1065767123': 838,\n",
       " '2705316616': 839,\n",
       " '1372844777': 840,\n",
       " '1568602075': 841,\n",
       " '1239204675': 842,\n",
       " '1701034943': 843,\n",
       " '1174211087': 844,\n",
       " '2526925550': 845,\n",
       " '1414791342': 846,\n",
       " '3365253328': 847,\n",
       " '1530694090': 848,\n",
       " '512403156': 849,\n",
       " '735155031': 850,\n",
       " '1766631338': 851,\n",
       " '3899853175': 852,\n",
       " '2112976085': 853,\n",
       " '1100202806': 854,\n",
       " '1769089355': 855,\n",
       " '1111636382': 856,\n",
       " '3626560268': 857,\n",
       " '622120837': 858,\n",
       " '1901632579': 859,\n",
       " '3129233779': 860,\n",
       " '1154950496': 861,\n",
       " '3818735309': 862,\n",
       " '761140108': 863,\n",
       " '2367415614': 864,\n",
       " '2691509364': 865,\n",
       " '3956263256': 866,\n",
       " '1669597962': 867,\n",
       " '1465929077': 868,\n",
       " '3875790954': 869,\n",
       " '1301205843': 870,\n",
       " '4212674087': 871,\n",
       " '3737890862': 872,\n",
       " '959032583': 873,\n",
       " '339060886': 874,\n",
       " '1722968298': 875,\n",
       " '2090317215': 876,\n",
       " '250948414': 877,\n",
       " '2175249529': 878,\n",
       " '1379372643': 879,\n",
       " '3565637257': 880,\n",
       " '1379282099': 881,\n",
       " '4021236305': 882,\n",
       " '1508286450': 883,\n",
       " '4208608073': 884,\n",
       " '2490258514': 885,\n",
       " '1484389215': 886,\n",
       " '633397465': 887,\n",
       " '3826870896': 888,\n",
       " '159812477': 889,\n",
       " '1074416596': 890,\n",
       " '797638314': 891,\n",
       " '1781140612': 892,\n",
       " '3224555758': 893,\n",
       " '2961046023': 894,\n",
       " '3372111380': 895,\n",
       " '794450376': 896,\n",
       " '4274310707': 897,\n",
       " '414015310': 898,\n",
       " '1708545365': 899,\n",
       " '24645215': 900,\n",
       " '3971391468': 901,\n",
       " '1991249255': 902,\n",
       " '168359768': 903,\n",
       " '454719225': 904,\n",
       " '1426337764': 905,\n",
       " '3317149544': 906,\n",
       " '4152301247': 907,\n",
       " '2072036921': 908,\n",
       " '2134876228': 909,\n",
       " '4259189014': 910,\n",
       " '234206875': 911,\n",
       " '2683060847': 912,\n",
       " '3490006930': 913,\n",
       " '3926217735': 914,\n",
       " '1039136952': 915,\n",
       " '3795400528': 916,\n",
       " '1547028922': 917,\n",
       " '2383225522': 918,\n",
       " '2507151007': 919,\n",
       " '824593257': 920,\n",
       " '2420562513': 921,\n",
       " '2529350528': 922,\n",
       " '1549996522': 923,\n",
       " '756986165': 924,\n",
       " '3265692358': 925,\n",
       " '4192985078': 926,\n",
       " '4089666658': 927,\n",
       " '3459360961': 928,\n",
       " '272472706': 929,\n",
       " '1128270383': 930,\n",
       " '3235943764': 931,\n",
       " '1850184598': 932,\n",
       " '1801869689': 933,\n",
       " '2556346032': 934,\n",
       " '798684088': 935,\n",
       " '3413478237': 936,\n",
       " '3843631351': 937,\n",
       " '2504283564': 938,\n",
       " '4223173683': 939,\n",
       " '1551306530': 940,\n",
       " '3448037031': 941,\n",
       " '549024328': 942,\n",
       " '1441699239': 943,\n",
       " '3479309219': 944,\n",
       " '3676836672': 945,\n",
       " '3480624055': 946,\n",
       " '2935280865': 947,\n",
       " '771655154': 948,\n",
       " '624162389': 949,\n",
       " '3581275802': 950,\n",
       " '606045790': 951,\n",
       " '1037047814': 952,\n",
       " '4101549335': 953,\n",
       " '2583766647': 954,\n",
       " '3818612808': 955,\n",
       " '3163258205': 956,\n",
       " '2804749662': 957,\n",
       " '2784973713': 958,\n",
       " '2373204206': 959,\n",
       " '1651087490': 960,\n",
       " '471005047': 961,\n",
       " '1549888315': 962,\n",
       " '2998407293': 963,\n",
       " '3593689705': 964,\n",
       " '111483358': 965,\n",
       " '2530418280': 966,\n",
       " '1921897790': 967,\n",
       " '1538644517': 968,\n",
       " '3689903524': 969,\n",
       " '2637341381': 970,\n",
       " '1944996876': 971,\n",
       " '341636399': 972,\n",
       " '2588804869': 973,\n",
       " '2142497014': 974,\n",
       " '690143024': 975,\n",
       " '664712104': 976,\n",
       " '2448320909': 977,\n",
       " '78250244': 978,\n",
       " '3976233788': 979,\n",
       " '1499252056': 980,\n",
       " '321597084': 981,\n",
       " '305513883': 982,\n",
       " '519818482': 983,\n",
       " '2155134627': 984,\n",
       " '2577147907': 985,\n",
       " '4129687445': 986,\n",
       " '1470185288': 987,\n",
       " '3434018694': 988,\n",
       " '3720406762': 989,\n",
       " '3759077194': 990,\n",
       " '3326402541': 991,\n",
       " '3644643572': 992,\n",
       " '53110486': 993,\n",
       " '1968146304': 994,\n",
       " '2542056792': 995,\n",
       " '454129950': 996,\n",
       " '2062562875': 997,\n",
       " '3616067928': 998,\n",
       " '4181743367': 999,\n",
       " ...}"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "eventIndex"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "13418"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(eventIndex)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "n_records = 0\n",
    "ftrain = open(\"train.csv\",\"r\")\n",
    "ftrain.readline()\n",
    "for line in ftrain:\n",
    "    cols = line.strip().split(\",\")\n",
    "    i = userIndex[cols[0]]\n",
    "    j = eventIndex[cols[1]]\n",
    "    \n",
    "    eventsForUser[i].add(j)\n",
    "    usersForEvent[j].add(i)\n",
    "    \n",
    "    score = int(cols[4])\n",
    "    userEventScores[i,j] = score\n",
    "ftrain.close()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "pickle.dump(eventsForUser,open(\"eventsForUser.pkl\",\"wb\"))\n",
    "pickle.dump(usersForEvent,open(\"usersForEvent.pkl\",\"wb\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "sio.mmwrite(\"userEventScores\",userEventScores)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "defaultdict(set,\n",
       "            {1998: {2170, 4988, 5599, 5778, 8143, 12045},\n",
       "             1919: {1778, 3108, 3743, 6972, 7513, 8859, 10298},\n",
       "             2928: {1091, 5871, 8520, 8732, 9980, 11688},\n",
       "             2772: {3480, 4673, 5666, 6330, 7027, 12859},\n",
       "             3061: {3486, 4560, 7882, 8000, 11967, 12781},\n",
       "             456: {1103,\n",
       "              2743,\n",
       "              3997,\n",
       "              4113,\n",
       "              4567,\n",
       "              4704,\n",
       "              5298,\n",
       "              6050,\n",
       "              6453,\n",
       "              7443,\n",
       "              7701,\n",
       "              7796,\n",
       "              7821,\n",
       "              9007},\n",
       "             1498: {1447, 4968, 7835, 8601, 9470, 10844},\n",
       "             1180: {2047, 4654, 4713, 6050, 6329, 10347},\n",
       "             2673: {2177, 2633, 4546, 5154, 7704, 9789, 11798},\n",
       "             1712: {313, 7550, 7780, 8239, 9848, 10021},\n",
       "             2709: {959, 1664, 5930, 7579, 8659, 8998},\n",
       "             361: {597, 1718, 6567, 6886, 7136, 7665},\n",
       "             731: {595, 839, 5777, 9009, 9142, 12846},\n",
       "             2853: {1511,\n",
       "              2142,\n",
       "              2170,\n",
       "              3221,\n",
       "              3367,\n",
       "              3668,\n",
       "              3936,\n",
       "              4425,\n",
       "              4667,\n",
       "              4988,\n",
       "              5081,\n",
       "              5599,\n",
       "              5614,\n",
       "              6050,\n",
       "              9091,\n",
       "              9963,\n",
       "              9981,\n",
       "              10761,\n",
       "              12018,\n",
       "              12701,\n",
       "              13320},\n",
       "             3124: {533, 5396, 6344, 8099, 9667, 10138},\n",
       "             1415: {1664, 2170, 4923, 4988, 5599, 6050, 9091, 10269, 12018},\n",
       "             2554: {523, 1027, 5890, 7176, 13024},\n",
       "             219: {281, 294, 2312, 4043, 5978, 8801},\n",
       "             645: {667, 1275, 2579, 9406, 13167},\n",
       "             713: {5951, 6334, 7168, 8842, 10369, 11165},\n",
       "             303: {165, 2329, 4255, 4356, 4853, 11379},\n",
       "             1625: {2170, 3367, 4988, 5599, 5614, 5749, 6050, 9091},\n",
       "             2213: {90, 3482, 5604, 5805, 9880, 11879, 13261},\n",
       "             896: {2621, 3308, 6447, 6558, 9522, 9965},\n",
       "             2992: {450, 3108, 3935, 6972, 10412, 11522},\n",
       "             2933: {950, 2329, 2473, 2515, 8809, 9081},\n",
       "             1121: {3135, 5511, 7193, 8693, 9159, 11862},\n",
       "             215: {868, 1017, 3677, 4402, 6846, 6917},\n",
       "             2678: {784, 2398, 5272, 6559, 6736, 10292, 12292},\n",
       "             1670: {3513, 4825, 5424, 6847, 9596, 10443, 10989},\n",
       "             2469: {78, 2351, 4060, 4737, 6050, 9091, 9549, 11819},\n",
       "             1194: {357, 4550, 7202, 8270, 10302, 11063, 11966},\n",
       "             494: {950, 2786, 5307, 6784},\n",
       "             1427: {2213,\n",
       "              5306,\n",
       "              6581,\n",
       "              9045,\n",
       "              10090,\n",
       "              11005,\n",
       "              11275,\n",
       "              12069,\n",
       "              12092,\n",
       "              13378},\n",
       "             513: {531,\n",
       "              910,\n",
       "              1338,\n",
       "              3414,\n",
       "              3916,\n",
       "              4403,\n",
       "              5492,\n",
       "              6451,\n",
       "              7147,\n",
       "              7323,\n",
       "              7364,\n",
       "              12924},\n",
       "             2796: {3108, 3417, 4551, 6335, 7816, 10412},\n",
       "             1070: {1284, 1429, 2487, 5276, 9309, 13274},\n",
       "             3372: {2170, 4379, 4923, 4988, 5599, 6050, 10193, 12274, 13012},\n",
       "             3077: {196, 5849, 8919, 9912, 12416, 13254},\n",
       "             26: {14, 3217, 4011, 4241, 6412, 6899, 8163, 9305, 12179},\n",
       "             643: {607, 4402, 5424, 7198, 9596, 10480, 10836},\n",
       "             2904: {2662, 3264, 3369, 5239, 9902, 11463},\n",
       "             1243: {893, 2633, 6153, 8020, 8065, 9081, 11028},\n",
       "             2429: {657, 1498, 1839, 5471, 8047, 8915, 11743},\n",
       "             216: {634,\n",
       "              740,\n",
       "              862,\n",
       "              2447,\n",
       "              3694,\n",
       "              5280,\n",
       "              5632,\n",
       "              6422,\n",
       "              7807,\n",
       "              10167,\n",
       "              10585,\n",
       "              13047},\n",
       "             2880: {656,\n",
       "              1027,\n",
       "              4449,\n",
       "              7053,\n",
       "              8020,\n",
       "              9081,\n",
       "              9482,\n",
       "              9850,\n",
       "              10645,\n",
       "              10971,\n",
       "              12118,\n",
       "              12332,\n",
       "              12972},\n",
       "             87: {1110, 1326, 2515, 2542, 9366, 9759, 11508},\n",
       "             1555: {2242, 3956, 5808, 7375, 9966, 11548},\n",
       "             2976: {1140, 1551, 1857, 4322, 6523, 11651},\n",
       "             2624: {10, 2771, 4988, 5298, 9007, 12717},\n",
       "             1333: {678, 7718, 8941, 9099},\n",
       "             1971: {561,\n",
       "              2170,\n",
       "              2306,\n",
       "              2691,\n",
       "              2895,\n",
       "              3243,\n",
       "              4359,\n",
       "              4923,\n",
       "              4988,\n",
       "              5576,\n",
       "              5599,\n",
       "              6050,\n",
       "              7581,\n",
       "              9091,\n",
       "              9118,\n",
       "              9254,\n",
       "              12018,\n",
       "              12595},\n",
       "             2650: {536,\n",
       "              671,\n",
       "              757,\n",
       "              860,\n",
       "              1522,\n",
       "              1800,\n",
       "              1816,\n",
       "              1882,\n",
       "              2029,\n",
       "              2535,\n",
       "              2620,\n",
       "              2665,\n",
       "              3353,\n",
       "              3547,\n",
       "              3608,\n",
       "              4107,\n",
       "              5826,\n",
       "              6942,\n",
       "              7461,\n",
       "              7698,\n",
       "              7938,\n",
       "              8027,\n",
       "              8093,\n",
       "              8265,\n",
       "              8733,\n",
       "              9999,\n",
       "              11013,\n",
       "              11384,\n",
       "              13131},\n",
       "             599: {661, 2329, 3401, 3666, 4559, 7407},\n",
       "             3305: {457, 2949, 4790, 5630, 5748, 10134},\n",
       "             132: {2515, 3615, 9081, 9789, 12558},\n",
       "             1020: {2692, 3774, 6843, 8064, 9483, 11607, 12833},\n",
       "             2780: {342, 2452, 2614, 10313, 11685, 12541},\n",
       "             98: {1942, 4253, 4683, 7129, 7935, 8289},\n",
       "             3373: {4667, 4923, 4988, 5599, 6050, 8168, 9091, 9324},\n",
       "             1094: {4988,\n",
       "              6050,\n",
       "              6965,\n",
       "              9091,\n",
       "              9487,\n",
       "              10271,\n",
       "              10594,\n",
       "              11896,\n",
       "              12701,\n",
       "              13036},\n",
       "             3050: {656, 2471, 5035, 6764, 7147, 7360, 10844, 11383},\n",
       "             1257: {2171, 5715, 8711, 8945, 10411, 10861, 11255},\n",
       "             1033: {154, 1533, 6856, 7646, 8809, 9081, 13386},\n",
       "             3157: {236, 1544, 1561, 4647, 7394, 11528, 12609},\n",
       "             1276: {2351, 4988, 6050, 9091, 10867, 11188},\n",
       "             1361: {782,\n",
       "              3261,\n",
       "              3769,\n",
       "              4060,\n",
       "              4893,\n",
       "              7697,\n",
       "              7958,\n",
       "              9612,\n",
       "              11219,\n",
       "              12286},\n",
       "             2575: {607, 2483, 4402, 5424, 7198, 10254, 12265},\n",
       "             107: {450, 3108, 3917, 7816, 10412, 10466},\n",
       "             2633: {953, 1028, 3497, 5608, 8643, 11012, 11928},\n",
       "             583: {1578, 1651, 7803, 9888, 12669, 13415},\n",
       "             1336: {3093, 3121, 9926, 12238},\n",
       "             2858: {4,\n",
       "              282,\n",
       "              1033,\n",
       "              1711,\n",
       "              2502,\n",
       "              4180,\n",
       "              5316,\n",
       "              6304,\n",
       "              7651,\n",
       "              9385,\n",
       "              10864,\n",
       "              12607},\n",
       "             2037: {298, 999, 2633, 2659, 7141, 11468},\n",
       "             910: {2233, 4256, 4764, 9850, 10101, 12881},\n",
       "             172: {265, 3169, 5424, 6022, 6847, 9596},\n",
       "             1325: {404, 678, 4988, 5207, 6050, 8699, 9091},\n",
       "             1808: {3108, 3417, 3935, 5171, 8859, 12814},\n",
       "             1836: {1951, 3919, 5365, 9081, 10645, 10790, 11927, 12118},\n",
       "             993: {1078, 2731, 3368, 4494, 5890},\n",
       "             1061: {905, 1841, 5948, 5966, 11322, 12502},\n",
       "             1960: {269,\n",
       "              891,\n",
       "              2170,\n",
       "              4995,\n",
       "              5599,\n",
       "              5614,\n",
       "              8579,\n",
       "              10168,\n",
       "              10502,\n",
       "              12253,\n",
       "              12680,\n",
       "              13412},\n",
       "             1364: {3048, 3918, 5580, 8682, 11772, 13081},\n",
       "             3195: {948, 2861, 3952, 4737, 11515, 11637, 12195},\n",
       "             3219: {276, 404, 3165, 3873, 4577, 10222},\n",
       "             2706: {282, 2192, 9515, 10691, 11248, 13163},\n",
       "             1885: {123, 3717, 5303, 5573, 6113, 7229, 8232, 12203},\n",
       "             2743: {3234,\n",
       "              3393,\n",
       "              4874,\n",
       "              6844,\n",
       "              6961,\n",
       "              7439,\n",
       "              8396,\n",
       "              9228,\n",
       "              10716,\n",
       "              11956,\n",
       "              12230,\n",
       "              12458,\n",
       "              13024},\n",
       "             885: {3223, 4988, 5419, 6050, 9091, 11808},\n",
       "             1429: {2176, 4055, 5105, 9846, 11754, 13269},\n",
       "             2583: {2483, 3169, 4402, 5424, 6390, 10164, 11164},\n",
       "             2384: {2649, 3111, 3287, 3857, 10500},\n",
       "             850: {433, 756, 1076, 2195, 9938, 10518},\n",
       "             2942: {558, 2057, 5673, 5906, 10581, 13033},\n",
       "             862: {946, 3249, 4403, 6036, 6050, 6643, 7519, 7958},\n",
       "             1740: {6631, 6918, 7296, 8425, 9444, 12456},\n",
       "             1606: {307, 4255, 4615, 4906, 7270, 8067, 9555},\n",
       "             1095: {2021, 2170, 4988, 5599, 5614, 6050, 7976},\n",
       "             912: {142,\n",
       "              2606,\n",
       "              3557,\n",
       "              4327,\n",
       "              4988,\n",
       "              5818,\n",
       "              6050,\n",
       "              8699,\n",
       "              11068,\n",
       "              11954,\n",
       "              12274,\n",
       "              12622,\n",
       "              12701},\n",
       "             2517: {51, 2031, 2381, 5771, 10128, 10284, 11322},\n",
       "             1175: {1015, 1573, 2014, 2981, 9224, 10935},\n",
       "             1182: {923, 4208, 5307, 8590, 9538, 10002, 11310},\n",
       "             1787: {450, 997, 5089, 5110, 7604, 8587, 11397, 13100},\n",
       "             250: {1765, 4245, 7163, 10571, 12572, 12943},\n",
       "             1989: {388, 1992, 9955, 10754, 12398, 12620},\n",
       "             261: {2922, 4266, 5188, 5358, 13209},\n",
       "             408: {2170,\n",
       "              4654,\n",
       "              4988,\n",
       "              5599,\n",
       "              6012,\n",
       "              6050,\n",
       "              6370,\n",
       "              6665,\n",
       "              8454,\n",
       "              9091,\n",
       "              9197,\n",
       "              11670,\n",
       "              12018},\n",
       "             662: {988, 2515, 2733, 8285, 9081, 9827},\n",
       "             3116: {1012, 6687, 7644, 11873},\n",
       "             2043: {950, 4820, 5286, 5986, 9081, 9681},\n",
       "             3003: {2483, 3169, 4402, 5424, 6022, 7198},\n",
       "             2025: {654, 1539, 1776, 2539, 8985, 10120, 12738, 13372},\n",
       "             1107: {2771, 2955, 6958, 8809, 9080, 12308},\n",
       "             2901: {2022, 4214, 5103, 8313, 13174},\n",
       "             1986: {1778, 4770, 6972, 8859, 9003, 9578, 12814},\n",
       "             1096: {2771, 4988, 6050, 9007, 12308, 12717},\n",
       "             2890: {656, 2240, 7053, 7632, 7725, 13127},\n",
       "             1117: {1881, 1996, 3612, 5664, 6230, 9012, 11401, 13133},\n",
       "             700: {3099, 6577, 8666, 9657, 10450, 10788},\n",
       "             1071: {1469, 5424, 6847, 9596, 10836, 13300},\n",
       "             354: {1514,\n",
       "              2982,\n",
       "              3443,\n",
       "              3895,\n",
       "              3930,\n",
       "              5499,\n",
       "              5835,\n",
       "              5870,\n",
       "              6460,\n",
       "              9247,\n",
       "              9367,\n",
       "              9502,\n",
       "              10531,\n",
       "              11178,\n",
       "              11426,\n",
       "              11901,\n",
       "              12309},\n",
       "             1999: {418, 1405, 5365, 10803, 12996},\n",
       "             1292: {1140, 2178, 4704, 7360, 10844, 13288},\n",
       "             2708: {1375, 3125, 4131, 6161, 9954, 11118},\n",
       "             1036: {1267, 1529, 2050, 3571, 5810, 10837},\n",
       "             1966: {10, 731, 1095, 2771, 7821, 9007, 12308},\n",
       "             3148: {953,\n",
       "              3497,\n",
       "              4087,\n",
       "              5771,\n",
       "              7296,\n",
       "              8226,\n",
       "              8487,\n",
       "              8895,\n",
       "              8931,\n",
       "              10300,\n",
       "              11248,\n",
       "              12456,\n",
       "              12636},\n",
       "             2225: {404, 5207, 7648, 7892, 11319, 12274},\n",
       "             3071: {209,\n",
       "              1823,\n",
       "              2071,\n",
       "              3040,\n",
       "              3959,\n",
       "              4519,\n",
       "              6244,\n",
       "              6626,\n",
       "              6761,\n",
       "              8368,\n",
       "              8960,\n",
       "              9434,\n",
       "              10859,\n",
       "              12708},\n",
       "             822: {1371,\n",
       "              1741,\n",
       "              2633,\n",
       "              3968,\n",
       "              4470,\n",
       "              5828,\n",
       "              8171,\n",
       "              9268,\n",
       "              10584,\n",
       "              10841,\n",
       "              11480,\n",
       "              11786},\n",
       "             1817: {2483, 4402, 5424, 6022, 10693, 10989},\n",
       "             2462: {1679, 2492, 4037, 6344, 7099, 11155},\n",
       "             1977: {658,\n",
       "              2170,\n",
       "              2419,\n",
       "              3516,\n",
       "              4527,\n",
       "              4988,\n",
       "              5216,\n",
       "              5419,\n",
       "              5599,\n",
       "              5614,\n",
       "              6050,\n",
       "              6395,\n",
       "              9091,\n",
       "              12033,\n",
       "              13298},\n",
       "             1868: {628,\n",
       "              749,\n",
       "              1248,\n",
       "              4159,\n",
       "              5298,\n",
       "              6272,\n",
       "              6381,\n",
       "              6754,\n",
       "              10666,\n",
       "              11242,\n",
       "              11543,\n",
       "              13219},\n",
       "             1129: {4402, 5424, 6847, 9429, 9596, 10164, 12265},\n",
       "             3100: {467, 3494, 7103, 7271, 9692, 12812},\n",
       "             1912: {1871, 2228, 9091, 9364, 9963, 10072, 10761, 11808},\n",
       "             2344: {4296, 5786, 7510, 7782, 8211, 9508},\n",
       "             2371: {428,\n",
       "              1217,\n",
       "              1653,\n",
       "              2818,\n",
       "              3867,\n",
       "              3934,\n",
       "              4788,\n",
       "              5529,\n",
       "              5716,\n",
       "              6876,\n",
       "              6943,\n",
       "              7234,\n",
       "              7562,\n",
       "              7899,\n",
       "              8806,\n",
       "              9857,\n",
       "              10001,\n",
       "              10360,\n",
       "              10599,\n",
       "              11302},\n",
       "             2899: {810, 3513, 5424, 6847, 9596, 10291},\n",
       "             1425: {2483, 3169, 3513, 4402, 5424, 8636},\n",
       "             1241: {702, 1436, 1549, 6940, 9957, 10983},\n",
       "             444: {656, 3970, 4499, 6229, 7632, 12798},\n",
       "             282: {207, 1150, 2385, 5122, 10808, 11572},\n",
       "             2493: {1973, 3748, 9209, 9850},\n",
       "             1143: {4403, 5970, 6050, 7713, 8946, 9091},\n",
       "             1560: {124, 1466, 3713, 4285, 11574, 12822},\n",
       "             113: {5424, 7198, 8636, 9429, 10164, 10443},\n",
       "             1686: {139, 533, 1315, 2329, 2915, 5336, 10390, 11014, 12835},\n",
       "             2731: {2001, 2733, 3771, 5596, 5669, 6571, 6764, 6997},\n",
       "             849: {1519, 2929, 4764, 6279, 10378, 13103},\n",
       "             3374: {895,\n",
       "              967,\n",
       "              4737,\n",
       "              4988,\n",
       "              6050,\n",
       "              6630,\n",
       "              9027,\n",
       "              9091,\n",
       "              11515,\n",
       "              11819,\n",
       "              12717},\n",
       "             2221: {2483, 4402, 5424, 6022, 6847, 9596},\n",
       "             2435: {265, 2483, 4336, 4402, 5424, 9429},\n",
       "             376: {731, 5298, 6050, 11515, 13085},\n",
       "             3030: {457, 5630, 8840, 8847, 9759, 10187, 11817, 12186},\n",
       "             1236: {1531, 3257, 5300, 6619, 10935, 12879},\n",
       "             833: {4604, 8805, 9087, 10425, 11410, 13268},\n",
       "             12: {2960, 5078, 5174, 5433, 5938, 6251},\n",
       "             3087: {193, 276, 4456, 6837, 6947, 9020},\n",
       "             3313: {5660, 5981, 8060, 9885, 11872, 12429},\n",
       "             697: {1540, 3278, 3372, 3842, 5672, 7057, 12911},\n",
       "             2281: {10, 731, 1716, 3123, 4988, 6050, 9007, 9091, 11515, 12717},\n",
       "             2591: {2476, 4661, 8591, 8603, 9457, 12492},\n",
       "             1507: {5545, 6022, 7198, 9429, 10836, 13300},\n",
       "             1315: {4402, 4825, 5424, 10164, 10443, 12265},\n",
       "             2104: {2483, 3169, 4402, 5424, 8636, 10164},\n",
       "             2356: {5092, 5207, 5331, 7184, 8699, 11873, 12818},\n",
       "             2634: {659,\n",
       "              1678,\n",
       "              3426,\n",
       "              5574,\n",
       "              7686,\n",
       "              9149,\n",
       "              10581,\n",
       "              12508,\n",
       "              12818,\n",
       "              12827},\n",
       "             650: {2925, 7926, 8304, 8721, 9511, 10486, 12709},\n",
       "             3267: {266, 2021, 5356, 7111, 9438, 12468},\n",
       "             401: {263, 6897, 8552, 9032, 12206, 12887},\n",
       "             1432: {1716, 2771, 2955, 6050, 8084, 9091, 9929},\n",
       "             1188: {1694, 3427, 4410, 5070, 5388, 8169, 10483, 12067, 12404},\n",
       "             2166: {770, 2607, 4350, 9366, 11468, 11508},\n",
       "             2836: {1504, 4000, 5247, 6050, 9091, 12818},\n",
       "             1973: {4346, 4483, 4980, 5521, 6429, 9296, 10125, 11266},\n",
       "             1332: {531, 910, 2943, 4403, 6050, 6285, 6622, 7323, 7364, 7369},\n",
       "             3355: {1951, 4321, 6344, 7140, 7209, 10645, 10971},\n",
       "             903: {1723, 2248, 6026, 6348, 8323, 12432},\n",
       "             373: {1738,\n",
       "              1852,\n",
       "              3503,\n",
       "              4327,\n",
       "              4494,\n",
       "              4561,\n",
       "              5352,\n",
       "              5841,\n",
       "              7345,\n",
       "              8129,\n",
       "              9126,\n",
       "              9290,\n",
       "              12525,\n",
       "              12881},\n",
       "             437: {3, 2594, 4894, 5855, 6889, 8383},\n",
       "             197: {2963, 4416, 7037, 9235, 9634, 13347},\n",
       "             626: {2315,\n",
       "              2431,\n",
       "              3963,\n",
       "              4403,\n",
       "              4947,\n",
       "              7364,\n",
       "              9426,\n",
       "              9876,\n",
       "              11501,\n",
       "              11606},\n",
       "             716: {885, 1177, 1449, 1981, 3246, 4060, 4088, 9612, 12271},\n",
       "             2900: {1028, 6452, 6918, 11355, 11928},\n",
       "             2654: {777, 1139, 3865, 4286, 8826, 9881},\n",
       "             93: {25, 1413, 4655, 9869, 10755, 11543, 12717},\n",
       "             2214: {611, 9675, 10957, 13185},\n",
       "             118: {102, 1263, 2803, 4596, 5755, 6224, 7932, 12361},\n",
       "             1700: {946, 2515, 2633, 4284, 4494, 9929},\n",
       "             881: {1615, 1712, 6580, 7288, 9198, 12487},\n",
       "             2032: {3417, 3935, 5318, 8986, 9082, 10466, 12178},\n",
       "             2782: {450, 3108, 3417, 6972, 9003, 12814},\n",
       "             2231: {894, 2216, 4789, 6145, 6783, 10447, 10664},\n",
       "             1583: {783, 2771, 5962, 6285, 7704, 12308},\n",
       "             1822: {641,\n",
       "              686,\n",
       "              2033,\n",
       "              6776,\n",
       "              9520,\n",
       "              10372,\n",
       "              10383,\n",
       "              10473,\n",
       "              11926,\n",
       "              12821},\n",
       "             1278: {950,\n",
       "              3717,\n",
       "              3823,\n",
       "              5006,\n",
       "              5035,\n",
       "              5394,\n",
       "              5420,\n",
       "              6410,\n",
       "              7704,\n",
       "              10820},\n",
       "             1270: {3968, 4470, 5300, 7863, 12142, 12879},\n",
       "             1877: {2566, 2580, 2696, 9687, 10010, 13373},\n",
       "             428: {753,\n",
       "              3203,\n",
       "              3676,\n",
       "              5681,\n",
       "              6030,\n",
       "              6062,\n",
       "              6134,\n",
       "              6299,\n",
       "              7362,\n",
       "              7868,\n",
       "              7995,\n",
       "              8253,\n",
       "              9043,\n",
       "              9145,\n",
       "              10182,\n",
       "              10537,\n",
       "              10583,\n",
       "              11157,\n",
       "              13342},\n",
       "             409: {265, 2483, 3169, 4402, 5424, 10164},\n",
       "             788: {1272, 2186, 9125, 9672},\n",
       "             984: {1909, 2170, 4988, 5599, 6050, 10598},\n",
       "             1383: {3513, 5424, 6022, 6509, 9429, 10989},\n",
       "             2222: {3169, 5424, 6022, 10164, 10836, 10989, 11164},\n",
       "             951: {3866, 4825, 5424, 9596, 10836, 10989},\n",
       "             368: {3407, 5164, 5446, 6922, 11393, 12952},\n",
       "             1988: {3048, 3918, 4422, 4812, 6486, 6697},\n",
       "             866: {3641, 8667, 8902, 9211, 10425, 12601},\n",
       "             624: {6930, 8449, 9231, 9331, 9602, 12094, 13009},\n",
       "             3056: {307,\n",
       "              1111,\n",
       "              1415,\n",
       "              1780,\n",
       "              3340,\n",
       "              4615,\n",
       "              6480,\n",
       "              7070,\n",
       "              7140,\n",
       "              8067,\n",
       "              9556,\n",
       "              10894,\n",
       "              11156},\n",
       "             744: {2875, 3931, 4988, 6050, 9091, 12701},\n",
       "             3099: {973, 4165, 4344, 6344, 8250, 9464, 9662, 11070, 11359},\n",
       "             119: {276, 404, 3834, 6050, 8659, 10158},\n",
       "             1465: {701, 1899, 5564, 5871, 6657},\n",
       "             2781: {983, 2878, 7402, 9228, 11804, 12865},\n",
       "             311: {10, 1716, 4988, 5298, 6050, 9091, 11515},\n",
       "             1321: {1356, 2165, 8150, 9007, 10222, 11454, 12308},\n",
       "             944: {276, 956, 5952, 8724, 10502, 12169},\n",
       "             1655: {4402, 5424, 8636, 10164, 10443, 11169},\n",
       "             1978: {739, 1878, 6200, 6582, 7989, 10361},\n",
       "             2526: {2150, 2170, 4988, 5599, 6050, 12973, 13137},\n",
       "             1059: {526, 4016, 8520, 8732, 9980, 11688},\n",
       "             1599: {2483, 3169, 4402, 5424, 7198, 10164},\n",
       "             2995: {491, 2228, 9091, 9963, 10307, 12074},\n",
       "             1256: {362, 514, 1981, 3246, 3261, 4988, 6050, 9612},\n",
       "             1614: {2483, 4402, 4825, 5424, 9596, 10254},\n",
       "             3274: {1186, 2734, 2977, 5754, 10829, 11623},\n",
       "             900: {2312, 2681, 4562, 5008, 7166, 9798, 13015},\n",
       "             3304: {2218, 3227, 3996, 5442, 7216},\n",
       "             2895: {760, 2191, 6417, 6543, 6695, 7444, 7822, 9773, 10304},\n",
       "             1529: {1215, 4890, 9205, 10482, 11614},\n",
       "             2262: {390, 2064, 2464, 3775, 8384, 10060},\n",
       "             3153: {404, 1909, 2170, 4988, 5614, 6050},\n",
       "             2974: {856,\n",
       "              2155,\n",
       "              3490,\n",
       "              4395,\n",
       "              5457,\n",
       "              5578,\n",
       "              7838,\n",
       "              9206,\n",
       "              10798,\n",
       "              12921},\n",
       "             751: {1753, 4953, 7001, 7538, 7990, 8494, 13404},\n",
       "             1238: {2206, 4257, 6749, 9205, 9519, 10515},\n",
       "             105: {546,\n",
       "              1045,\n",
       "              1342,\n",
       "              2460,\n",
       "              3089,\n",
       "              3267,\n",
       "              3690,\n",
       "              5547,\n",
       "              5760,\n",
       "              6469,\n",
       "              6999,\n",
       "              7495,\n",
       "              7815,\n",
       "              8103,\n",
       "              8346,\n",
       "              8474,\n",
       "              8578,\n",
       "              9867,\n",
       "              9958,\n",
       "              10573,\n",
       "              10739,\n",
       "              12433,\n",
       "              13374},\n",
       "             425: {282, 2010, 4983, 6577, 8040, 11322, 12636},\n",
       "             2062: {915, 4018, 7885, 8245, 8518, 12257},\n",
       "             1786: {291, 6160, 9102, 10835, 10966, 11123},\n",
       "             3293: {2338, 2746, 2783, 10590, 11977, 12915},\n",
       "             3078: {230, 2069, 5364, 6025, 9698, 13115},\n",
       "             3260: {2434, 3107, 6354, 7459, 7710, 10100},\n",
       "             222: {5643, 7085, 7654, 9951, 12641, 13275},\n",
       "             1611: {447, 449, 558, 4230, 5801, 11643, 12760},\n",
       "             1087: {731, 2771, 5336, 7789, 7958, 9007, 9204, 9736, 12308},\n",
       "             448: {946, 6016, 7958, 11836, 13099},\n",
       "             2065: {165, 1662, 2731, 5890, 6544, 9033},\n",
       "             420: {2515, 6240, 10222, 10645, 10971},\n",
       "             814: {28, 5610, 7578, 8762, 9620, 11020},\n",
       "             1330: {1655, 8128, 8809, 9827, 12313, 12618},\n",
       "             301: {165, 1758, 3558, 3919, 4356, 5890, 9328},\n",
       "             616: {758, 1015, 6050, 7392, 8460, 13078},\n",
       "             1539: {1801, 2526, 3737, 4988, 10072, 12701},\n",
       "             238: {533, 555, 1405, 3836, 9081, 10150},\n",
       "             2195: {4402, 5424, 7198, 9596, 10164, 10443},\n",
       "             443: {334, 659, 3209, 9519, 10581, 10914},\n",
       "             3271: {6080, 7773, 7996, 11156, 11836},\n",
       "             2179: {362, 4737, 4988, 6050, 11515, 12717},\n",
       "             2767: {1078, 6997, 10436, 12152, 12230},\n",
       "             2461: {5045, 5183, 6835, 12077, 12706, 12748},\n",
       "             517: {1505, 1577, 4293, 6397, 9797, 11729},\n",
       "             44: {218,\n",
       "              235,\n",
       "              1385,\n",
       "              2020,\n",
       "              3695,\n",
       "              4211,\n",
       "              4682,\n",
       "              5565,\n",
       "              6064,\n",
       "              7053,\n",
       "              7711,\n",
       "              8775,\n",
       "              9186,\n",
       "              9416,\n",
       "              9850,\n",
       "              10543,\n",
       "              10896,\n",
       "              10941,\n",
       "              11837,\n",
       "              12791,\n",
       "              12972,\n",
       "              13288},\n",
       "             2854: {2483, 4402, 5424, 8636, 10443, 11169},\n",
       "             2514: {9, 2845, 9190, 12083, 12091, 12144},\n",
       "             3238: {647,\n",
       "              2219,\n",
       "              3760,\n",
       "              5136,\n",
       "              6476,\n",
       "              6689,\n",
       "              7668,\n",
       "              8151,\n",
       "              9749,\n",
       "              9951,\n",
       "              11482,\n",
       "              13275},\n",
       "             37: {1536, 1709, 2567, 6040, 11472, 12707},\n",
       "             2471: {950, 3948, 4306, 4337, 7646, 8128, 12155},\n",
       "             472: {632, 3605, 5067, 10014, 10151, 13237},\n",
       "             2596: {5424, 6847, 8109, 9596, 10836, 11169},\n",
       "             1002: {265,\n",
       "              607,\n",
       "              2946,\n",
       "              4641,\n",
       "              5545,\n",
       "              6022,\n",
       "              7198,\n",
       "              9429,\n",
       "              11586,\n",
       "              13300},\n",
       "             631: {886, 1807, 4723, 8851, 10679, 13159},\n",
       "             321: {735, 1592, 2035, 2534, 8984, 11379},\n",
       "             2664: {2170, 4577, 4988, 5599, 5614, 6050, 8092, 12628},\n",
       "             2626: {2373, 3512, 4780, 5046, 8411, 13055},\n",
       "             2961: {5424, 6022, 6847, 7198, 9596, 10164},\n",
       "             276: {450, 3108, 3417, 3935, 9497, 10412},\n",
       "             1418: {276, 2170, 4988, 5599, 5614, 6050},\n",
       "             2305: {69, 6096, 9435, 9792, 10627, 11261},\n",
       "             1595: {3365, 4662, 4988, 5575, 12495},\n",
       "             898: {165,\n",
       "              194,\n",
       "              416,\n",
       "              1280,\n",
       "              1655,\n",
       "              2093,\n",
       "              2473,\n",
       "              2515,\n",
       "              3460,\n",
       "              3615,\n",
       "              4255,\n",
       "              4853,\n",
       "              8536,\n",
       "              9081,\n",
       "              10645,\n",
       "              10871,\n",
       "              12418,\n",
       "              12558},\n",
       "             1591: {159, 4848, 7214, 9695, 11983},\n",
       "             3035: {2169, 2532, 3590, 5782, 10341, 12285},\n",
       "             647: {4180, 6084, 8226, 8900, 10424, 11322},\n",
       "             1281: {4615, 5867, 7140, 7794, 9081, 13085},\n",
       "             3158: {4445, 9192, 9547, 10375, 11761, 13182},\n",
       "             759: {905, 2481, 4576, 5465, 6871},\n",
       "             2310: {5962, 6050, 7364, 9091, 9538, 9973, 10222},\n",
       "             2293: {6781, 11181, 11949, 12025, 12324, 12344},\n",
       "             3259: {47,\n",
       "              67,\n",
       "              2635,\n",
       "              2737,\n",
       "              3048,\n",
       "              3391,\n",
       "              4018,\n",
       "              4689,\n",
       "              7550,\n",
       "              7847,\n",
       "              8239,\n",
       "              9235,\n",
       "              9849,\n",
       "              10648,\n",
       "              10791,\n",
       "              11039,\n",
       "              11386,\n",
       "              11989},\n",
       "             2620: {4988, 6050, 9091, 11068, 12336, 12818},\n",
       "             1035: {194, 307, 2515, 7713, 8809, 9789, 12340, 12758},\n",
       "             1688: {2170, 4988, 5599, 5614, 6050, 9935},\n",
       "             3201: {928, 1764, 2936, 4631, 6867, 7566, 10190},\n",
       "             2495: {2639, 2947, 7140, 8988, 9922, 11253},\n",
       "             506: {194, 5047, 5837, 7319, 12418, 12545},\n",
       "             79: {4069,\n",
       "              5178,\n",
       "              5726,\n",
       "              6545,\n",
       "              7327,\n",
       "              9799,\n",
       "              11366,\n",
       "              12133,\n",
       "              12837,\n",
       "              12853},\n",
       "             1603: {4402, 5424, 7198, 10164, 12265},\n",
       "             340: {607, 2483, 4402, 5424, 6847, 9596},\n",
       "             1: {1646, 1792, 1964, 3454, 3816, 4496, 4775, 12783},\n",
       "             1608: {905, 1841, 4576, 6487, 8567, 10049, 11322},\n",
       "             3380: {1921, 5996, 9188, 10201, 11149, 12460},\n",
       "             2329: {404, 1587, 1696, 3489, 4988, 6050},\n",
       "             535: {1015, 1291, 3257, 5020, 11549},\n",
       "             3284: {4954, 7080, 7228, 11240, 12892, 13411},\n",
       "             151: {4652, 5478, 9307, 12287, 12858},\n",
       "             2797: {994, 2170, 4988, 5599, 5614, 6050, 7812},\n",
       "             1484: {551, 2505, 3333, 4871, 5273, 10220, 10588, 13376},\n",
       "             2272: {4645, 6766, 6823, 9564, 10509, 11113},\n",
       "             2502: {868, 2483, 3677, 5998, 6917, 11988},\n",
       "             2831: {1266, 3512, 4780, 8633, 12277},\n",
       "             1217: {783, 4403, 4988, 6050, 6302, 7559, 7958, 11515, 12717},\n",
       "             1943: {1180, 3368, 6549, 7366, 7599, 8415},\n",
       "             2857: {2170, 4380, 4988, 5599, 6050, 6340},\n",
       "             3366: {2170, 4988, 5092, 5599, 6050, 9091, 12018, 12973},\n",
       "             1115: {2170, 4654, 4988, 5599, 8699, 11670},\n",
       "             1543: {234, 701, 1255, 1674, 6891, 8924},\n",
       "             562: {707, 1482, 4607, 4903, 5351, 7647},\n",
       "             1078: {3801, 5745, 6900, 7480, 8567, 8640, 8952, 11322, 13039},\n",
       "             776: {2798, 3048, 3768, 4851, 9794, 12066},\n",
       "             2936: {1632, 2633, 5155, 5298, 9789, 12545},\n",
       "             3047: {1465, 7821, 8730, 9556, 10222, 10858, 10993},\n",
       "             569: {450, 1640, 3108, 3417, 10298},\n",
       "             1622: {2266,\n",
       "              2562,\n",
       "              3271,\n",
       "              4255,\n",
       "              4264,\n",
       "              6384,\n",
       "              6795,\n",
       "              7153,\n",
       "              7773,\n",
       "              9290,\n",
       "              11781},\n",
       "             1028: {2288, 2326, 3191, 6266, 8653, 10011, 11585, 13240},\n",
       "             108: {779, 2453, 2599, 6438, 8531, 11076, 11669},\n",
       "             2764: {1826, 3223, 4988, 5988, 6050, 9091},\n",
       "             2987: {5877, 10825, 11357, 12941},\n",
       "             2809: {278, 3430, 4079, 4427, 5468, 6624},\n",
       "             385: {1177, 1798, 3379, 10078, 10497, 11151, 12750},\n",
       "             606: {3, 793, 7933, 8761, 9826, 10516},\n",
       "             2540: {3774, 7570, 8064, 9483, 9808, 10037},\n",
       "             941: {1638, 1877, 5641, 6094, 6288, 8621},\n",
       "             1458: {394, 596, 968, 5244, 5789, 12422},\n",
       "             2251: {494, 2775, 6672, 7022, 7588, 8442, 11640},\n",
       "             2958: {120,\n",
       "              471,\n",
       "              863,\n",
       "              909,\n",
       "              1203,\n",
       "              1909,\n",
       "              5053,\n",
       "              6151,\n",
       "              6693,\n",
       "              6868,\n",
       "              8604,\n",
       "              9761,\n",
       "              10335},\n",
       "             3015: {3215, 3991, 8455, 9998},\n",
       "             1258: {159, 5424, 8520, 9695, 10015, 12860},\n",
       "             163: {336,\n",
       "              477,\n",
       "              2048,\n",
       "              2107,\n",
       "              4020,\n",
       "              4407,\n",
       "              5609,\n",
       "              6132,\n",
       "              8739,\n",
       "              10923,\n",
       "              10924,\n",
       "              11531},\n",
       "             417: {2791, 3123, 3942, 4275, 4988, 5298, 12717},\n",
       "             1034: {1699, 5425, 7033, 7192, 10572, 12546},\n",
       "             1216: {4038,\n",
       "              4621,\n",
       "              4789,\n",
       "              5929,\n",
       "              6058,\n",
       "              8098,\n",
       "              8130,\n",
       "              9086,\n",
       "              9726,\n",
       "              9947,\n",
       "              10400,\n",
       "              10429,\n",
       "              12469,\n",
       "              12732},\n",
       "             3204: {3681, 4443, 7283, 7666, 10415, 11903},\n",
       "             1522: {148, 5392, 6010, 9995, 11565, 12773},\n",
       "             2656: {846, 867, 6163, 6896, 8076, 10696},\n",
       "             2172: {64, 4403, 5970, 6050, 8456, 9238, 10868},\n",
       "             1284: {1669,\n",
       "              2168,\n",
       "              2676,\n",
       "              2768,\n",
       "              3540,\n",
       "              4066,\n",
       "              4121,\n",
       "              4132,\n",
       "              6968,\n",
       "              7047,\n",
       "              7370,\n",
       "              9167,\n",
       "              10261,\n",
       "              11857,\n",
       "              13138},\n",
       "             2475: {3623, 3745, 6813, 7059, 9049, 9845, 11175, 12942, 13124},\n",
       "             2006: {38, 487, 1218, 7269, 9895, 11463},\n",
       "             2813: {533, 3001, 6229, 7632, 9681, 11059, 12798},\n",
       "             810: {1659, 1951, 6080, 8356, 9556, 10971, 12340},\n",
       "             2721: {2597, 2826, 3228, 4508, 7948, 9110, 11503},\n",
       "             1897: {2804, 3016, 4920, 10031, 11086, 13302},\n",
       "             3389: {3602, 3935, 5318, 6972, 7132, 8859, 9082, 12178},\n",
       "             998: {1173, 1713, 4657, 10245, 10277, 11463},\n",
       "             2334: {2170, 3196, 4988, 5599, 5614, 6050, 12818},\n",
       "             3202: {1357, 4746, 4816, 6095, 6128, 6320, 8562, 10127},\n",
       "             2513: {945, 2791, 3020, 5298},\n",
       "             2966: {48, 392, 1070, 1526, 1686, 2515, 2633, 2791},\n",
       "             3017: {950, 2515, 5155, 6344, 8343, 10645},\n",
       "             2682: {118, 763, 4403, 5192, 6016, 6375},\n",
       "             351: {3997, 8515, 10041, 10093, 10443, 11872},\n",
       "             115: {2143, 6405, 10630, 11894},\n",
       "             1334: {533, 4394, 4644, 5493, 5776, 12904},\n",
       "             1313: {3085, 5329, 6798, 9390, 10570, 10724, 10764, 12372},\n",
       "             530: {2483,\n",
       "              3169,\n",
       "              4402,\n",
       "              5424,\n",
       "              6847,\n",
       "              7198,\n",
       "              8636,\n",
       "              9596,\n",
       "              10155,\n",
       "              10164,\n",
       "              12265},\n",
       "             74: {915, 4836, 8376, 10021, 11709, 12386},\n",
       "             1049: {404, 2142, 4072, 4988, 5599, 6050, 9091, 12018},\n",
       "             2018: {1266, 4780, 5193, 5893, 9236, 9347},\n",
       "             1538: {167, 522, 2483, 3238, 5998, 10443},\n",
       "             2768: {363, 2170, 4577, 4988, 5614, 9609},\n",
       "             1099: {2473, 6216, 8356, 9574, 9590, 10871},\n",
       "             3004: {1300, 1484, 3241, 3861, 4981, 6007, 6193, 8821, 9157},\n",
       "             2394: {937, 1166, 4910, 5214, 5657, 5731, 8085, 8553, 10257},\n",
       "             2861: {533,\n",
       "              946,\n",
       "              2416,\n",
       "              2633,\n",
       "              2664,\n",
       "              3198,\n",
       "              4070,\n",
       "              4197,\n",
       "              7646,\n",
       "              7843,\n",
       "              8390,\n",
       "              9016,\n",
       "              9905,\n",
       "              10746,\n",
       "              12778,\n",
       "              12926,\n",
       "              13386},\n",
       "             2403: {2710, 2948, 6273, 7674, 9222, 10142, 11980},\n",
       "             2134: {2636, 4119, 4895, 11947, 12373, 12862},\n",
       "             2807: {40,\n",
       "              564,\n",
       "              608,\n",
       "              1754,\n",
       "              3265,\n",
       "              3824,\n",
       "              3910,\n",
       "              4220,\n",
       "              4435,\n",
       "              6747,\n",
       "              7337,\n",
       "              7685,\n",
       "              8608,\n",
       "              8725,\n",
       "              9273,\n",
       "              9945,\n",
       "              12093},\n",
       "             263: {5097, 5488, 5559, 8187, 12250, 12674},\n",
       "             2569: {4050, 5933, 8826, 9704, 11574, 11873, 12185},\n",
       "             1613: {318,\n",
       "              1026,\n",
       "              3364,\n",
       "              5002,\n",
       "              6683,\n",
       "              7916,\n",
       "              7962,\n",
       "              9570,\n",
       "              11484,\n",
       "              11875},\n",
       "             974: {376,\n",
       "              918,\n",
       "              1812,\n",
       "              2023,\n",
       "              2271,\n",
       "              2906,\n",
       "              4274,\n",
       "              4388,\n",
       "              4545,\n",
       "              8814,\n",
       "              9852,\n",
       "              11072,\n",
       "              12367},\n",
       "             804: {136, 3601, 7291, 7703, 7777, 11339},\n",
       "             622: {419, 698, 2468, 4222, 4763, 12132, 12834},\n",
       "             158: {450, 3108, 3417, 3935, 6972, 7513, 9791, 10915},\n",
       "             1944: {310, 1085, 2889, 5722, 8922, 9660},\n",
       "             2088: {1334, 3556, 4384, 6736, 6944, 11498},\n",
       "             2273: {731,\n",
       "              2771,\n",
       "              2791,\n",
       "              4988,\n",
       "              6050,\n",
       "              7821,\n",
       "              8873,\n",
       "              9007,\n",
       "              10993,\n",
       "              11454,\n",
       "              12308},\n",
       "             2111: {2135, 2348, 7397, 8799},\n",
       "             3288: {668, 7903, 9648, 10016, 10971, 11567},\n",
       "             2885: {2483, 4402, 4825, 5424, 10443, 12265},\n",
       "             1434: {1993, 4400, 4913, 5218, 8338, 8537},\n",
       "             2550: {4063, 4951, 5315, 5423, 7949, 12787},\n",
       "             1372: {2483, 4402, 5424, 7198, 8787, 10164, 10693},\n",
       "             2911: {3169, 4402, 4825, 5424, 7198, 10836},\n",
       "             812: {2389, 6517, 9755, 11050, 11195, 12273},\n",
       "             106: {104, 276, 3733, 11777, 12680, 12927},\n",
       "             327: {4725, 5010, 8081, 10805, 11232, 11873, 12818},\n",
       "             111: {2574, 6181, 8081, 8097, 9292, 9363, 11852, 11873},\n",
       "             325: {531, 910, 4403, 6050, 7323, 7364},\n",
       "             3208: {44, 4460, 5068, 5691, 6344, 9556, 11238},\n",
       "             1280: {1732, 3524, 3624, 3831, 5661, 9443},\n",
       "             3186: {2483, 4402, 5424, 7038, 8636, 9429, 10164},\n",
       "             2652: {2971, 6820, 10050, 12193, 12589, 13221},\n",
       "             2341: {404, 1055, 2021, 5331, 11873, 12185, 12818},\n",
       "             1513: {699,\n",
       "              3450,\n",
       "              4819,\n",
       "              5616,\n",
       "              6127,\n",
       "              8958,\n",
       "              9083,\n",
       "              9670,\n",
       "              9897,\n",
       "              12383,\n",
       "              12549,\n",
       "              13096},\n",
       "             2279: {7298, 7881, 8200, 11185, 11903, 12666},\n",
       "             2109: {6405, 6687, 8081, 8925, 10581, 11873},\n",
       "             2674: {5290, 7448, 7540, 9461, 11377, 13301},\n",
       "             1343: {391, 591, 3514, 6385, 6963, 11004},\n",
       "             1931: {3539, 5365, 8415, 8809, 9081, 12558},\n",
       "             1439: {3829, 4034, 4988, 6050, 7818, 10162, 12818},\n",
       "             2568: {142, 682, 959, 4988, 6050, 6157, 6439, 9091, 9128, 12818},\n",
       "             1843: {718, 4285, 7152, 12551, 12584, 13128},\n",
       "             1732: {1436, 3105, 3194, 3633, 3683, 7617, 8830, 11961, 12400},\n",
       "             2364: {1689, 6311, 7405, 7462, 8892, 11724},\n",
       "             1150: {282, 1028, 6918, 9515, 10691, 11322, 11928},\n",
       "             3295: {1479,\n",
       "              2284,\n",
       "              3871,\n",
       "              5630,\n",
       "              5825,\n",
       "              9730,\n",
       "              10187,\n",
       "              11943,\n",
       "              12186,\n",
       "              12282,\n",
       "              13098},\n",
       "             574: {2329, 7559, 9681, 10645, 12991, 13362},\n",
       "             2071: {1187, 6078, 7548, 9275, 10366, 11916},\n",
       "             1287: {3558, 3919, 5420, 5682, 9033, 11927, 12230, 12332},\n",
       "             1542: {2194, 3108, 3935, 6972, 7513, 9003},\n",
       "             2482: {80, 1468, 2212, 6201, 8322, 12980},\n",
       "             1172: {1290, 2382, 3730, 4182, 5314, 6516},\n",
       "             400: {288,\n",
       "              1001,\n",
       "              2249,\n",
       "              2344,\n",
       "              2827,\n",
       "              3853,\n",
       "              4505,\n",
       "              5705,\n",
       "              6173,\n",
       "              7417,\n",
       "              7631,\n",
       "              7726,\n",
       "              7736,\n",
       "              8167,\n",
       "              8364,\n",
       "              8521,\n",
       "              9088,\n",
       "              9181,\n",
       "              9458,\n",
       "              10735,\n",
       "              11358,\n",
       "              12068},\n",
       "             1358: {6079, 9898, 11854, 12310, 12482, 12898},\n",
       "             1266: {459, 946, 1003, 1930, 5299, 8115, 8908, 10703, 12715},\n",
       "             2917: {128, 1871, 6965, 6974, 7316, 10409},\n",
       "             2679: {1981, 2228, 2761, 3246, 3303, 5419},\n",
       "             2486: {1237, 3737, 5142, 8727, 9185, 10071, 12450, 13217},\n",
       "             543: {2060, 2677, 2796, 3736, 4216, 4729, 8645, 11380},\n",
       "             2396: {2524, 6511, 7860, 11435, 12201, 13239},\n",
       "             1051: {2536, 7214, 8520, 11419, 11983, 12860},\n",
       "             990: {2315, 4627, 5063, 5236, 10101},\n",
       "             1303: {1216, 1600, 8119, 11231, 12110, 12692},\n",
       "             929: {2170, 4988, 5599, 5614, 6050, 9091},\n",
       "             1007: {1576, 5054, 8832, 11847},\n",
       "             3125: {1259, 1427, 2644, 6175, 9485, 9939, 12852},\n",
       "             411: {731, 2771, 4988, 6050, 8809, 9007, 11515, 12308, 12717},\n",
       "             2263: {1770, 1944, 4733, 6537, 9790, 12626},\n",
       "             3281: {62, 477, 2011, 4837, 8216, 9134, 10998, 11818},\n",
       "             3338: {3169, 3513, 5424, 6847, 9429, 9596},\n",
       "             696: {3512, 4780, 5046, 6873, 7934, 8411, 9267},\n",
       "             2996: {3497, 4582, 5015, 5190, 7722, 8755, 10051},\n",
       "             2081: {626, 1568, 1691, 3535, 9241, 10844},\n",
       "             418: {404, 678, 2170, 4988, 5216, 5599, 6050, 7508, 9091, 9397},\n",
       "             2830: {6375, 7476, 8414, 9556, 12259, 13114},\n",
       "             3197: {549,\n",
       "              932,\n",
       "              965,\n",
       "              1351,\n",
       "              2130,\n",
       "              2435,\n",
       "              4856,\n",
       "              5367,\n",
       "              5790,\n",
       "              6136,\n",
       "              8300,\n",
       "              8978,\n",
       "              10698,\n",
       "              11861,\n",
       "              13325},\n",
       "             2769: {1778, 2531, 3743, 3982, 8859, 9335, 12670},\n",
       "             3006: {2170, 4988, 5599, 6050, 9091, 12018},\n",
       "             2865: {5424, 7214, 8520, 8758, 11419, 12860},\n",
       "             2252: {5424, 6022, 6847, 7198, 9596, 10836},\n",
       "             1729: {868,\n",
       "              3513,\n",
       "              4371,\n",
       "              4402,\n",
       "              5424,\n",
       "              6917,\n",
       "              7541,\n",
       "              8636,\n",
       "              10443,\n",
       "              10693,\n",
       "              10830,\n",
       "              11537},\n",
       "             2956: {1951, 6302, 9033, 9866, 11836, 12230},\n",
       "             2586: {1533, 3468, 4255, 6856, 9081, 9827},\n",
       "             3033: {1365, 2428, 4155, 8432, 12660, 13133},\n",
       "             1713: {3920, 5452, 6019, 6267, 6726, 7863},\n",
       "             2570: {4294, 4406, 5774, 7384, 7855, 11235, 12741},\n",
       "             160: {2058, 2076, 3573, 4804, 5301, 6507, 7967, 8234, 8734},\n",
       "             2783: {222, 5570, 6508, 7619, 8296, 9879, 10601, 10802},\n",
       "             2510: {1841, 4952, 6918, 7651, 11322, 13180},\n",
       "             2607: {1729, 1990, 2968, 3337, 6331, 12876},\n",
       "             476: {2170, 4667, 5614, 9449},\n",
       "             2473: {879, 2145, 2312, 2681, 4248, 6047},\n",
       "             2735: {483, 6050, 9042, 9091, 10568, 13239},\n",
       "             2203: {1700, 3108, 3614, 3743, 3935, 8859, 10915},\n",
       "             1684: {257, 1029, 2704, 4199, 8690, 10427},\n",
       "             3299: {404, 2170, 4988, 8605, 10725, 12622},\n",
       "             2138: {4534, 7315, 7670, 9302, 9389, 11584, 12009},\n",
       "             1510: {7198, 9429, 9596, 10824, 10836, 10989},\n",
       "             412: {777, 1827, 2096, 3358, 4050, 9437, 10815},\n",
       "             63: {2968, 3002, 6064, 7147, 7756, 12554},\n",
       "             2078: {212, 651, 2876, 5009, 6589, 8887, 9712, 11917},\n",
       "             2649: {1900, 7214, 8520, 8732, 9980, 11688},\n",
       "             1399: {1268, 4340, 4403, 5962, 6050, 6473, 7364, 9091, 10491},\n",
       "             2322: {950, 2329, 4853, 5624, 8809},\n",
       "             2567: {4402, 5611, 6456, 6790, 10443, 12429},\n",
       "             868: {3083, 3123, 3483, 4988, 5298, 6050, 11515, 11543, 12717},\n",
       "             103: {4197, 4961, 6442, 9017, 9555, 12948},\n",
       "             2089: {2483, 3169, 3513, 4402, 5424, 6847, 10164},\n",
       "             1275: {10, 891, 2165, 2771, 9007, 10491, 10712, 12308},\n",
       "             1659: {1413, 1690, 5458, 6016, 8225, 9310, 9830, 13402},\n",
       "             2132: {1030, 5671, 6536, 7040, 10066, 12680},\n",
       "             2739: {3007,\n",
       "              3116,\n",
       "              4198,\n",
       "              6178,\n",
       "              6212,\n",
       "              6268,\n",
       "              7401,\n",
       "              8034,\n",
       "              8324,\n",
       "              9210,\n",
       "              11758,\n",
       "              11826},\n",
       "             1886: {1261, 2699, 6280, 8361, 9179, 10999, 12968, 13337},\n",
       "             2294: {2791, 5970, 6285, 7299, 10421, 11594},\n",
       "             135: {946, 1701, 2401, 3893, 5201, 8456, 11993},\n",
       "             3298: {1729, 3536, 4705, 7809, 8232, 9689},\n",
       "             922: {1447, 7632, 7906, 8538, 9074, 9271},\n",
       "             2133: {4402, 4825, 5424, 6847, 9596, 10155, 10443},\n",
       "             346: {1892, 3195, 3634, 4113, 7796, 7844, 7883, 10204},\n",
       "             2529: {435, 528, 1557, 4591, 6914, 10643, 12353},\n",
       "             3131: {1764,\n",
       "              2868,\n",
       "              3916,\n",
       "              4327,\n",
       "              4826,\n",
       "              5392,\n",
       "              5423,\n",
       "              7796,\n",
       "              11606,\n",
       "              11895,\n",
       "              12196,\n",
       "              13298},\n",
       "             2150: {4737,\n",
       "              4988,\n",
       "              6050,\n",
       "              6444,\n",
       "              9091,\n",
       "              10867,\n",
       "              11290,\n",
       "              11518,\n",
       "              11819,\n",
       "              12371},\n",
       "             1174: {2515, 6229, 8876, 9681, 10803, 12155},\n",
       "             853: {276, 404, 1205, 2170, 2454, 4988, 5599, 6050, 10939},\n",
       "             1208: {5834, 6054, 7945, 8683, 9439},\n",
       "             1777: {3, 1940, 9826, 11016, 12862, 13396},\n",
       "             1451: {363, 1282, 4273, 8242, 9397, 12033},\n",
       "             1813: {302,\n",
       "              1108,\n",
       "              1359,\n",
       "              2119,\n",
       "              2211,\n",
       "              4877,\n",
       "              6691,\n",
       "              7272,\n",
       "              8303,\n",
       "              8367,\n",
       "              9333,\n",
       "              9360,\n",
       "              10385,\n",
       "              10880,\n",
       "              11469,\n",
       "              12443},\n",
       "             3303: {2483, 3169, 4402, 5424, 8636, 10164},\n",
       "             1196: {1899, 4402, 5424, 6847, 9596, 10693},\n",
       "             1073: {1611, 5051, 5357, 8372, 8675, 10883, 11935},\n",
       "             710: {2483, 3169, 4402, 5424, 10164, 10836},\n",
       "             1762: {491, 1177, 2103, 2228, 4988, 6050},\n",
       "             2875: {2483,\n",
       "              3169,\n",
       "              3513,\n",
       "              4402,\n",
       "              5424,\n",
       "              6847,\n",
       "              7198,\n",
       "              9596,\n",
       "              10155,\n",
       "              11169},\n",
       "             1259: {2028, 2480, 4709, 6356, 6489, 12211},\n",
       "             2883: {5424, 6022, 6847, 10443, 10836, 10989},\n",
       "             515: {1965, 2228, 2299, 4988, 6050, 9091},\n",
       "             1373: {2483, 3169, 4825, 5424, 6847, 9596},\n",
       "             1450: {377, 2236, 6941, 7220, 9166, 11369},\n",
       "             475: {1826, 1876, 2932, 9091, 11658},\n",
       "             2784: {2633, 2757, 7917, 9122, 10354, 12515, 12598},\n",
       "             2919: {6527, 7174, 9576, 9581, 11117},\n",
       "             2722: {292, 2515, 6465, 8710, 9218, 10526, 11821, 12872},\n",
       "             1296: {2100, 8689, 10222, 11337, 11727, 12881},\n",
       "             2592: {858, 2246, 6100, 7197, 10513, 10536},\n",
       "             1163: {76,\n",
       "              259,\n",
       "              299,\n",
       "              429,\n",
       "              685,\n",
       "              875,\n",
       "              2397,\n",
       "              2444,\n",
       "              3053,\n",
       "              3124,\n",
       "              3183,\n",
       "              3667,\n",
       "              4200,\n",
       "              4295,\n",
       "              4578,\n",
       "              4741,\n",
       "              5371,\n",
       "              5577,\n",
       "              5925,\n",
       "              6083,\n",
       "              6415,\n",
       "              6735,\n",
       "              6893,\n",
       "              7257,\n",
       "              7767,\n",
       "              8088,\n",
       "              8161,\n",
       "              8282,\n",
       "              8311,\n",
       "              8565,\n",
       "              8586,\n",
       "              8785,\n",
       "              8825,\n",
       "              8857,\n",
       "              9044,\n",
       "              9104,\n",
       "              9843,\n",
       "              10154,\n",
       "              10343,\n",
       "              10389,\n",
       "              10457,\n",
       "              10729,\n",
       "              10731,\n",
       "              11019,\n",
       "              11161,\n",
       "              11659,\n",
       "              11878,\n",
       "              11992,\n",
       "              12845},\n",
       "             500: {3108, 3614, 6972, 10298, 10661, 12814},\n",
       "             707: {1464, 3717, 4506, 8232, 9956, 11297, 11773},\n",
       "             397: {1215, 3905, 7306, 9394, 9673, 10322},\n",
       "             1305: {3108, 3476, 4551, 9003, 10298, 12814},\n",
       "             1678: {4988, 5340, 6050, 8572, 10489, 12701},\n",
       "             1493: {991, 2808, 4766, 6003, 8292, 10751},\n",
       "             1637: {79,\n",
       "              861,\n",
       "              1470,\n",
       "              2184,\n",
       "              2202,\n",
       "              2976,\n",
       "              3384,\n",
       "              4690,\n",
       "              4956,\n",
       "              5328,\n",
       "              5555,\n",
       "              5658,\n",
       "              6449,\n",
       "              6590,\n",
       "              6599,\n",
       "              6731,\n",
       "              7871,\n",
       "              8596,\n",
       "              8628,\n",
       "              10538,\n",
       "              11686,\n",
       "              11822,\n",
       "              12105,\n",
       "              12507,\n",
       "              12855,\n",
       "              12917,\n",
       "              13260},\n",
       "             520: {3000, 3180, 4367, 5236, 7147, 9952},\n",
       "             2886: {573, 734, 8001, 9518, 10321, 11322, 11699},\n",
       "             2335: {6871, 8094, 8563, 10503, 11100, 11333, 12965},\n",
       "             3109: {417, 1116, 1434, 2078, 3753, 3849, 6976, 8090, 9358, 9572},\n",
       "             2472: {592, 827, 1109, 1204, 4096, 8777, 9147, 12007, 12957},\n",
       "             1571: {574, 2172, 2557, 4535, 7874, 8445, 9353, 12355},\n",
       "             1928: {455, 7235, 8205, 10632, 11463, 12527},\n",
       "             2365: {276, 1543, 5614, 6391, 8159, 12818},\n",
       "             1218: {2743, 5243, 5564, 6720, 9474, 10561},\n",
       "             2487: {5599, 5614, 6050, 8251, 8447, 9091, 9709},\n",
       "             808: {3457, 5589, 6365, 7817, 9637, 11270},\n",
       "             3096: {1280, 1951, 2473, 5890, 8356, 12332},\n",
       "             1237: {138, 799, 5964, 9072, 11315, 11470},\n",
       "             1745: {1814, 4172, 5421, 6588, 8642, 11104, 11532, 12138},\n",
       "             1519: {6196, 7644, 9567, 10445, 11873, 12336},\n",
       "             2127: {2687, 3011, 3022, 9106, 9622},\n",
       "             938: {1101,\n",
       "              1339,\n",
       "              1599,\n",
       "              3367,\n",
       "              5081,\n",
       "              7688,\n",
       "              8572,\n",
       "              8605,\n",
       "              11777,\n",
       "              12818},\n",
       "             1706: {135, 3113, 6395, 6572, 8560},\n",
       "             1801: {2308, 5868, 11624, 11782, 12652, 13294},\n",
       "             2247: {1382, 1829, 2105, 2114, 3989, 10139},\n",
       "             1584: {510,\n",
       "              985,\n",
       "              1206,\n",
       "              1370,\n",
       "              1634,\n",
       "              2352,\n",
       "              2667,\n",
       "              2974,\n",
       "              8492,\n",
       "              10285,\n",
       "              10333,\n",
       "              10913},\n",
       "             657: {1534, 3402, 5733, 7277, 7441, 7956, 8013, 8107, 8450, 9599},\n",
       "             831: {495, 5624, 6473, 7472, 8128, 12547},\n",
       "             2139: {99,\n",
       "              1622,\n",
       "              2071,\n",
       "              2298,\n",
       "              4757,\n",
       "              5100,\n",
       "              7966,\n",
       "              8360,\n",
       "              8729,\n",
       "              8838,\n",
       "              9234,\n",
       "              10878,\n",
       "              11148,\n",
       "              12086,\n",
       "              12267,\n",
       "              12393,\n",
       "              12529,\n",
       "              12538,\n",
       "              13274},\n",
       "             326: {2705, 5180, 8277, 8651, 9244, 11137},\n",
       "             615: {404, 2170, 4988, 5599, 6050, 11779},\n",
       "             230: {607, 2483, 3513, 4402, 4825, 5424, 10443},\n",
       "             1293: {425, 3743, 4770, 8859, 9003, 9578},\n",
       "             537: {165, 2291, 4880, 5890, 7332, 9328, 9603, 13403},\n",
       "             723: {1154, 1903, 3513, 9186},\n",
       "             2902: {731, 1148, 9007, 11882, 11968, 12308},\n",
       "             1139: {1841, 5948, 7651, 8203, 10788, 11322},\n",
       "             897: {2483, 4402, 5424, 7198, 9429, 10164, 10836},\n",
       "             509: {656, 2754, 2794, 9850, 10860, 12972, 13024},\n",
       "             310: {1051, 1730, 2831, 8306, 9437, 12863},\n",
       "             3172: {2016, 2540, 3031, 8572, 8704},\n",
       "             2001: {1078, 1951, 4805, 6229, 11224, 11836},\n",
       "             3094: {4402, 4825, 5424, 7198, 8787, 9596},\n",
       "             1360: {3153, 3531, 3559, 5051, 5552, 8397, 8562, 10077, 11935},\n",
       "             3014: {3362, 5196, 5244, 6332, 7608, 7826, 7993, 10212, 12988},\n",
       "             2453: {3417, 5437, 5550, 7816, 8748, 8778, 10466, 12053},\n",
       "             2399: {306, 1302, 3513, 5336, 6022, 10836},\n",
       "             914: {1776, 3586, 8985, 9872, 12738, 13372},\n",
       "             3199: {2170, 3936, 5599, 9981, 12198, 13152},\n",
       "             338: {306, 4825, 5424, 6022, 6847, 9596, 12381},\n",
       "             691: {3169, 4402, 5424, 7198, 10164, 10443, 10693},\n",
       "             721: {1982, 5560, 9968, 10425, 12574, 12910},\n",
       "             913: {115, 1711, 5899, 6668, 9530, 9627, 12700},\n",
       "             1011: {450, 3108, 4551, 7816, 8859, 9497, 10412, 11061},\n",
       "             1050: {668, 2280, 2329, 7620, 10944, 10971},\n",
       "             1155: {787, 1515, 1927, 5113, 6562, 11873},\n",
       "             3306: {251, 2633, 6240, 9789, 10354, 11142},\n",
       "             805: {163,\n",
       "              285,\n",
       "              2040,\n",
       "              2820,\n",
       "              2863,\n",
       "              2871,\n",
       "              2877,\n",
       "              4128,\n",
       "              5534,\n",
       "              6288,\n",
       "              6389,\n",
       "              6437,\n",
       "              6841,\n",
       "              9495,\n",
       "              10458,\n",
       "              10529,\n",
       "              10612,\n",
       "              11183,\n",
       "              11295,\n",
       "              11566,\n",
       "              11612,\n",
       "              12126,\n",
       "              12354,\n",
       "              12365,\n",
       "              13063},\n",
       "             164: {1679, 2771, 3306, 7958, 10222, 11727},\n",
       "             218: {2002, 2220, 6021, 6888, 8763, 11372},\n",
       "             3178: {2926, 3485, 4379, 4988, 8489, 12476},\n",
       "             4: {2481, 2801, 4180, 9515, 9518, 11672, 13163},\n",
       "             2631: {5158, 5602, 8041, 8491, 12944, 12949},\n",
       "             11: {265, 3169, 5424, 6022, 10836, 11169},\n",
       "             2957: {3791, 6587, 6723, 6980, 9909, 10198, 10701},\n",
       "             836: {645, 3143, 3799, 6363, 6913, 11326},\n",
       "             689: {3366, 5036, 8448, 8702, 9732, 10350, 11787},\n",
       "             1724: {771, 1892, 3634, 5315, 5629, 7796, 12503},\n",
       "             2732: {1298, 1410, 7399, 7467, 10226, 12906},\n",
       "             88: {2170, 2743, 4988, 5599, 5614, 6050},\n",
       "             1530: {220, 1675, 6607, 7313, 7359, 7500},\n",
       "             39: {2660, 5742, 7308, 9201, 9795, 12966},\n",
       "             259: {5424, 6847, 9596, 10164, 10254, 10989},\n",
       "             245: {946, 1494, 1958, 7128, 11993, 12028},\n",
       "             1499: {244, 905, 1841, 2381, 3844, 5382, 5948, 11138, 11333},\n",
       "             195: {1652, 3048, 4018, 7014, 7550, 8239, 13173},\n",
       "             1548: {3818, 5647, 9023, 9318, 12078, 13247},\n",
       "             240: {10, 731, 2771, 5298, 9007, 12308},\n",
       "             3111: {3169, 5424, 6022, 7198, 8109, 10164},\n",
       "             3362: {1072, 1177, 2633, 3424, 11040, 12701},\n",
       "             1840: {2483, 4402, 4825, 5424, 6847, 9596},\n",
       "             1849: {158,\n",
       "              1736,\n",
       "              1860,\n",
       "              2051,\n",
       "              2600,\n",
       "              2723,\n",
       "              2806,\n",
       "              4319,\n",
       "              4585,\n",
       "              5717,\n",
       "              5791,\n",
       "              5999,\n",
       "              6110,\n",
       "              6924,\n",
       "              8315,\n",
       "              8357,\n",
       "              8624,\n",
       "              9778,\n",
       "              9782,\n",
       "              10772,\n",
       "              10990,\n",
       "              11538,\n",
       "              11944,\n",
       "              12029,\n",
       "              12661},\n",
       "             1523: {783, 6050, 7559, 8147, 9538, 12991},\n",
       "             2494: {1859, 4030, 4060, 4911, 7110, 7330, 7830},\n",
       "             1389: {7246, 8964, 11141, 12017, 12513, 12823},\n",
       "             1086: {2483, 3169, 3513, 4402, 5424, 6022, 13300},\n",
       "             3011: {3, 369, 3655, 5377, 9826, 10477},\n",
       "             2602: {271, 1361, 1503, 4784, 4865, 12675},\n",
       "             2978: {262, 683, 855, 7533, 10694, 10851},\n",
       "             1181: {2329, 3086, 4337, 7254, 9081, 10971},\n",
       "             1549: {67,\n",
       "              242,\n",
       "              957,\n",
       "              1025,\n",
       "              3048,\n",
       "              4941,\n",
       "              5217,\n",
       "              6707,\n",
       "              7847,\n",
       "              8613,\n",
       "              11616,\n",
       "              13121},\n",
       "             2121: {249, 1875, 4579, 5401, 7810, 8451},\n",
       "             1756: {2281, 2801, 4180, 5497, 6084, 10864, 11322},\n",
       "             255: {1909, 2170, 4988, 5614, 8168, 9935},\n",
       "             192: {2801, 4180, 6918, 8900, 10864, 12477},\n",
       "             709: {750, 946, 3627, 4559, 5718, 6566, 6866, 7534, 8189},\n",
       "             322: {1313, 5053, 7018, 10335, 11199, 11447, 13107},\n",
       "             357: {2483, 3262, 3677, 4402, 10443, 12265},\n",
       "             1405: {2170, 4988, 5614, 7145, 7248, 11876},\n",
       "             1585: {4532, 7931, 8485, 8650, 8813, 10428},\n",
       "             894: {1277, 2392, 6551, 9415, 12449, 12767},\n",
       "             2859: {1395, 8028, 8527, 11342, 11454, 11608},\n",
       "             3090: {731, 1070, 2329, 2791, 5298, 6050},\n",
       "             2224: {2842, 4123, 5879, 7184, 8435, 11045},\n",
       "             3363: {282, 1028, 7669, 9515, 9949, 11322},\n",
       "             2181: {811, 1460, 4372, 4535, 4736, 7048, 12799},\n",
       "             429: {2192, 4180, 5771, 6577, 11248, 12636},\n",
       "             185: {4403, 5706, 5970, 6050, 7364, 9091, 11727},\n",
       "             708: {763, 2329, 4403, 6050, 7364, 9091, 11606},\n",
       "             3173: {3513, 3866, 5424, 6022, 8636, 10164, 10836, 13300},\n",
       "             2488: {404, 482, 3969, 5778, 11873, 12691},\n",
       "             2927: {959, 4988, 6050, 8188, 8489, 12760},\n",
       "             2142: {2414, 4619, 4994, 5162, 7471, 10239, 13248},\n",
       "             1750: {4211, 4978, 6518, 7035, 7053, 7360},\n",
       "             109: {1611, 3017, 5051, 6477, 8372, 9884, 10243, 10883},\n",
       "             2746: {5183, 6835, 10351, 10899, 11201, 12496},\n",
       "             756: {4403, 4410, 5970, 9290, 12524, 12881},\n",
       "             2434: {2170,\n",
       "              2574,\n",
       "              4654,\n",
       "              4988,\n",
       "              5092,\n",
       "              5599,\n",
       "              6050,\n",
       "              6597,\n",
       "              7248,\n",
       "              8971,\n",
       "              10542,\n",
       "              12973},\n",
       "             1586: {1664, 4654, 4988, 5599, 6050, 6370},\n",
       "             1074: {1289, 2170, 3675, 4988},\n",
       "             832: {1175, 1683, 2738, 2918, 5839, 10833, 11995},\n",
       "             95: {668,\n",
       "              1280,\n",
       "              1846,\n",
       "              2473,\n",
       "              2900,\n",
       "              4287,\n",
       "              4363,\n",
       "              4499,\n",
       "              7673,\n",
       "              9750,\n",
       "              10625,\n",
       "              13362},\n",
       "             2197: {380, 1276, 2003, 4191, 6171, 9706, 13071},\n",
       "             927: {2602, 3404, 4815, 5119, 5669, 6737},\n",
       "             2518: {1469, 5424, 6847, 7198, 9596, 10164},\n",
       "             1797: {731,\n",
       "              891,\n",
       "              2292,\n",
       "              2771,\n",
       "              4755,\n",
       "              4899,\n",
       "              6050,\n",
       "              9284,\n",
       "              9327,\n",
       "              9523,\n",
       "              10353,\n",
       "              10669,\n",
       "              11281,\n",
       "              11863,\n",
       "              12841},\n",
       "             2117: {168, 3622, 3672, 8160, 9132, 10846},\n",
       "             602: {2771, 9007, 9789, 11512, 11968, 12308},\n",
       "             878: {2289, 2730, 6617, 7789, 11216, 12993},\n",
       "             2267: {1526, 5205, 6880, 7821, 9081, 10645},\n",
       "             3253: {1043, 1120, 2701, 6195, 7819, 11173},\n",
       "             538: {412,\n",
       "              731,\n",
       "              2771,\n",
       "              3968,\n",
       "              4753,\n",
       "              4838,\n",
       "              4988,\n",
       "              5297,\n",
       "              6050,\n",
       "              7863,\n",
       "              8965,\n",
       "              9007,\n",
       "              9317,\n",
       "              11066,\n",
       "              12308,\n",
       "              12879},\n",
       "             3066: {853, 1293, 5202, 5240, 12688},\n",
       "             2312: {105, 1579, 1717, 3159, 7633, 11015, 11318},\n",
       "             2505: {892, 1285, 2395, 8378, 9775, 10713},\n",
       "             563: {3024, 4153, 4158, 4643, 6722, 6956, 7667, 8959, 9348},\n",
       "             1878: {929, 3583, 5131, 5797, 9041, 10023, 13025},\n",
       "             3325: {1161, 5749, 8037, 10175, 10502, 12680},\n",
       "             2265: {1716, 2297, 5844, 7984, 11515, 12717},\n",
       "             2206: {1455, 1919, 2809, 2835, 9871, 12587, 13085},\n",
       "             3048: {3614, 3935, 8859, 8986, 9082, 9267, 12194},\n",
       "             1760: {1880, 6685, 6956, 8755, 9475, 10005, 11208},\n",
       "             3206: {6694, 8157, 9625, 11103},\n",
       "             613: {5424, 6022, 6847, 9596, 10155},\n",
       "             1437: {1427, 2378, 2978, 5594, 6175, 9827},\n",
       "             2000: {1070, 5970, 6050, 7821, 11594, 12761},\n",
       "             2553: {3492, 4120, 4918, 11082, 11767, 12883},\n",
       "             2423: {2483, 4402, 5424, 6847, 7198, 9596},\n",
       "             3270: {467, 1196, 5903, 9193, 9692, 10315, 12388},\n",
       "             1634: {4884, 4900, 6834, 7725, 8601, 9182, 12024},\n",
       "             1130: {2170, 2260, 4988, 5599, 6050, 9963, 10858, 11805},\n",
       "             3235: {3906, 4073, 4245, 4626, 6086, 7854},\n",
       "             1904: {67, 1989, 3978, 8206, 11599, 12806},\n",
       "             381: {1326, 1386, 2014, 6017, 8501, 10365, 10408, 11316},\n",
       "             3059: {865, 1301, 3960, 4704, 7035, 8222, 11209, 12818},\n",
       "             3297: {1083, 2099, 4146, 8524, 8892, 9641},\n",
       "             575: {1665, 1871, 4988, 6050, 9963, 12701},\n",
       "             1387: {1020, 1526, 3072, 7369, 12332, 12458},\n",
       "             2828: {3178, 3631, 6807, 9161},\n",
       "             2617: {57, 1075, 2829, 3652, 7039, 8570, 11660},\n",
       "             3349: {3413, 5336, 6424, 9366, 11508, 13092},\n",
       "             2730: {1879, 3021, 7680, 8431, 10004, 12141},\n",
       "             728: {404, 1567, 4988, 6050, 9091, 10499},\n",
       "             1687: {5424, 7198, 9429, 10254, 10836, 10989},\n",
       "             1746: {3513, 5424, 6022, 7198, 10155, 10164, 13300},\n",
       "             2530: {172, 3819, 4176, 6180, 10208, 12875},\n",
       "             639: {103, 8538, 9850, 10844, 10925},\n",
       "             2357: {276, 363, 3090, 5599, 6050, 6289, 8605, 12680},\n",
       "             46: {2483, 4402, 5424, 9596, 10254, 10443, 10693},\n",
       "             1876: {1948, 4586, 8716, 8956, 9272, 9998, 10214, 10753},\n",
       "             3106: {48, 2515, 2947, 4503, 4674, 7140, 9081, 12558, 12592},\n",
       "             684: {2075, 2116, 6525, 7426, 9371, 10052, 12176},\n",
       "             213: {967, 2228, 4988, 6050, 7110, 8961, 9230, 11485, 12933},\n",
       "             2298: {3119, 5069, 6401, 12617},\n",
       "             2217: {3048, 4851, 6778, 8914, 11097, 12066},\n",
       "             3149: {4559, 6741, 9789, 10280, 10960, 11216, 12881},\n",
       "             2094: {656, 1998, 6571, 7053, 9427, 10982},\n",
       "             2095: {438, 2269, 3250, 5883, 5989, 10495, 11843},\n",
       "             2733: {48, 850, 2515, 10526, 13085, 13377},\n",
       "             1192: {2771, 4988, 6050, 11515, 12308, 12717},\n",
       "             146: {6050, 8075, 9084, 9280, 9991, 12701},\n",
       "             184: {5424, 5545, 6847, 9596, 10443, 10836, 11169},\n",
       "             89: {950, 2515, 3302, 6954, 9005, 9081},\n",
       "             1639: {2144, 4302, 7320, 7496, 9613, 12818},\n",
       "             1339: {2483, 4402, 5424, 8636, 10164, 10693},\n",
       "             1793: {668, 6229, 8356, 8876, 10971, 11059},\n",
       "             188: {1825, 3436, 6716, 9615, 10908, 12080},\n",
       "             145: {7011, 8722, 9834, 10906, 11155, 11938},\n",
       "             190: {780, 1869, 8495, 9579, 11493, 12856},\n",
       "             1232: {100, 505, 3130, 3270, 11147, 12071, 13313},\n",
       "             1598: {7682, 10756, 10789, 10793, 12664, 13199},\n",
       "             383: {2092, 2282, 7065, 8846, 10863, 11365},\n",
       "             1662: {731, 2771, 4988, 6050, 8873, 9007, 11515, 12308, 12717},\n",
       "             2984: {4403, 4826, 5970, 6050, 7364, 8238, 9091, 11067},\n",
       "             875: {6718, 8826, 9437, 10815, 11673, 12719},\n",
       "             3175: {398, 950, 2515, 2630, 2633, 2743, 2756, 8020, 11567},\n",
       "             2912: {2329, 4255, 8809, 9081},\n",
       "             2295: {1483, 2548, 2924, 3768, 11303, 13211},\n",
       "             116: {770, 1031, 1169, 4364, 8710, 10526},\n",
       "             1267: {4522, 4988, 5298, 11066, 11454, 12717},\n",
       "             416: {910, 4403, 5655, 6050, 7323, 7364},\n",
       "             2023: {897, 2046, 2720, 7287, 11294, 12962},\n",
       "             1457: {610, 4988, 6050, 7464, 9091, 10356},\n",
       "             928: {2483, 3169, 5424, 6022, 10164, 10836},\n",
       "             469: {485, 2231, 2641, 3597, 5029, 5814, 8413},\n",
       "             2599: {218, 1865, 3486, 5025, 10844, 11153},\n",
       "             334: {372, 3367, 3511, 3943, 7247, 13205},\n",
       "             3129: {2961, 3614, 4517, 5318, 8859, 12178},\n",
       "             1821: {2708, 2856, 5848, 8069, 11200, 11317},\n",
       "             2773: {258,\n",
       "              1473,\n",
       "              2275,\n",
       "              2571,\n",
       "              2727,\n",
       "              3684,\n",
       "              4907,\n",
       "              4984,\n",
       "              4991,\n",
       "              5748,\n",
       "              5876,\n",
       "              6681,\n",
       "              7727,\n",
       "              7930,\n",
       "              8014,\n",
       "              8215,\n",
       "              8380,\n",
       "              8869,\n",
       "              9417,\n",
       "              10104,\n",
       "              10405,\n",
       "              10505,\n",
       "              10620,\n",
       "              12772,\n",
       "              13398},\n",
       "             1705: {879, 2312, 2858, 4645, 5800, 6722},\n",
       "             2742: {1602, 3315, 4594, 4610, 6963, 13056},\n",
       "             2703: {2170,\n",
       "              4353,\n",
       "              4408,\n",
       "              4988,\n",
       "              5614,\n",
       "              5675,\n",
       "              6050,\n",
       "              8042,\n",
       "              8508,\n",
       "              8691,\n",
       "              10502,\n",
       "              12336,\n",
       "              12973,\n",
       "              13164},\n",
       "             1268: {1078, 7357, 8190, 9850, 10723, 13288},\n",
       "             2369: {3014, 4581, 6884, 11241, 11284, 12763},\n",
       "             1345: {4825, 5424, 6022, 6847, 8636, 9596},\n",
       "             1699: {188, 3632, 4971, 5628, 6956, 9530, 10472},\n",
       "             549: {1951,\n",
       "              2329,\n",
       "              3783,\n",
       "              4832,\n",
       "              5890,\n",
       "              7559,\n",
       "              9554,\n",
       "              10638,\n",
       "              11836,\n",
       "              11927,\n",
       "              12230},\n",
       "             2415: {2801, 4180, 9515, 11322, 12636, 13321},\n",
       "             1556: {2935, 3581, 5484, 8057, 10133, 10485},\n",
       "             588: {5337, 7069, 7616, 8811, 9743, 12176},\n",
       "             3073: {1343, 4922, 5228, 10148, 10266, 10472},\n",
       "             665: {868, 3677, 4402, 6917, 10443, 11625, 12265},\n",
       "             439: {2315,\n",
       "              4403,\n",
       "              5970,\n",
       "              6050,\n",
       "              6285,\n",
       "              7364,\n",
       "              8566,\n",
       "              9030,\n",
       "              9091,\n",
       "              9290,\n",
       "              10323,\n",
       "              11021,\n",
       "              11727},\n",
       "             604: {1950, 5965, 11463, 12172, 12427, 12839},\n",
       "             1751: {2329, 2515, 4255, 4663, 10645, 10971},\n",
       "             1123: {746, 2753, 5129, 6635, 7374, 7851},\n",
       "             3032: {3018, 3825, 7053, 7360, 7428, 7841},\n",
       "             352: {7530, 8248, 11828, 12184, 12245},\n",
       "             1440: {4288, 6248, 6713, 6789, 7567, 11204},\n",
       "             597: {2483, 3169, 3513, 4402, 5424, 7198, 9429, 10164},\n",
       "             3332: {2067, 4403, 4826, 6050, 7364, 9091, 12048},\n",
       "             3226: {403,\n",
       "              500,\n",
       "              1316,\n",
       "              2440,\n",
       "              4277,\n",
       "              5326,\n",
       "              5689,\n",
       "              5939,\n",
       "              7491,\n",
       "              10338,\n",
       "              13399},\n",
       "             3296: {2483, 3513, 4402, 5424, 7198, 10164},\n",
       "             1947: {42, 3987, 4966, 7082, 9056, 12728},\n",
       "             765: {2515, 4233, 5429, 5558, 6544, 7903, 9827},\n",
       "             1845: {3474, 4020, 6226, 9121, 11576, 11848},\n",
       "             3039: {1044,\n",
       "              1863,\n",
       "              2569,\n",
       "              2846,\n",
       "              5432,\n",
       "              7694,\n",
       "              9057,\n",
       "              9820,\n",
       "              10105,\n",
       "              10132,\n",
       "              10626,\n",
       "              11127,\n",
       "              11885,\n",
       "              11888,\n",
       "              11909,\n",
       "              12301},\n",
       "             3166: {3338, 3720, 4050, 4251, 4779, 5235},\n",
       "             2454: {4050, 6687, 6775, 6827, 7306, 10581, 11873},\n",
       "             3334: {1744, 2858, 6427, 6722, 8684, 12338},\n",
       "             2519: {2581, 5792, 6842, 8995, 11220, 11587},\n",
       "             2907: {1078, 1951, 3368, 6591, 10832, 10903},\n",
       "             1948: {2170, 4988, 5599, 5614, 6050, 11068},\n",
       "             2786: {193, 276, 3073, 5599, 6050},\n",
       "             1663: {39, 399, 1097, 1327, 1761, 6721, 7071, 8232, 12462},\n",
       "             1489: {2170, 4988, 5599, 6050, 9091, 12973},\n",
       "             1900: {434,\n",
       "              1194,\n",
       "              1794,\n",
       "              1856,\n",
       "              1957,\n",
       "              1974,\n",
       "              1979,\n",
       "              2405,\n",
       "              2839,\n",
       "              2847,\n",
       "              3334,\n",
       "              3812,\n",
       "              3938,\n",
       "              4133,\n",
       "              5491,\n",
       "              5520,\n",
       "              6627,\n",
       "              7078,\n",
       "              7977,\n",
       "              8309,\n",
       "              8385,\n",
       "              9069,\n",
       "              9647,\n",
       "              10086,\n",
       "              10487,\n",
       "              10954,\n",
       "              11003,\n",
       "              11018,\n",
       "              12227,\n",
       "              12249,\n",
       "              12278,\n",
       "              12330},\n",
       "             512: {1776, 6592, 6878, 8464, 8985, 12073},\n",
       "             1093: {2512, 4202, 4212, 6258, 8712, 8920},\n",
       "             581: {950, 1564, 2633, 5472, 9538, 9556},\n",
       "             3227: {964, 1731, 2044, 4494, 4542, 9556},\n",
       "             1379: {4403, 5970, 6050, 7364, 9091, 9538},\n",
       "             1245: {946, 7673, 9556, 9772, 11666},\n",
       "             1474: {2192, 2801, 4180, 6084, 8466, 11322},\n",
       "             331: {4263, 6307, 7915, 10334, 10937, 11602},\n",
       "             1779: {4494, 8232, 8395, 11836, 12149, 13099},\n",
       "             3105: {884, 6445, 9091, 11777, 11907, 12701},\n",
       "             1204: {1128, 3796, 4769, 7771, 10246, 12276},\n",
       "             2939: {3628, 5182, 7000, 9908},\n",
       "             1463: {4402, 5166, 5424, 6847, 9596, 10254},\n",
       "             1824: {531, 656, 910, 2315, 3727, 4403, 7364},\n",
       "             1195: {2238, 3864, 7391, 8861},\n",
       "             480: {813, 2521, 3835, 4716, 5200, 9493},\n",
       "             1557: {450, 1778, 3108, 3743, 8859, 12814},\n",
       "             386: {2170, 4988, 5599, 6050, 9091, 12018},\n",
       "             2027: {1078, 2568, 5119, 7439, 9276, 12735},\n",
       "             378: {868, 2007, 4371, 6917, 10041, 10443},\n",
       "             452: {133, 1078, 5172, 7231, 12003, 12635},\n",
       "             1344: {3169, 5424, 6022, 6509, 7198, 11164, 11169, 13300},\n",
       "             237: {946, 4887, 5788, 7506, 8779, 11993, 12720},\n",
       "             2753: {1916, 3312, 4471, 7737, 9075, 10147},\n",
       "             2317: {2483, 3169, 4402, 5424, 6022, 9191},\n",
       "             1888: {2943, 4403, 6050, 7364, 9030, 9091, 10961, 12404},\n",
       "             1955: {2021, 2170, 4988, 5599, 6050, 12033},\n",
       "             2512: {404,\n",
       "              1212,\n",
       "              1215,\n",
       "              1870,\n",
       "              6687,\n",
       "              7088,\n",
       "              8826,\n",
       "              11192,\n",
       "              11873,\n",
       "              12505,\n",
       "              12757},\n",
       "             1128: {2483, 4402, 4825, 5424, 9596, 10443},\n",
       "             986: {399,\n",
       "              702,\n",
       "              1078,\n",
       "              1388,\n",
       "              2947,\n",
       "              3558,\n",
       "              3755,\n",
       "              4917,\n",
       "              7376,\n",
       "              7639,\n",
       "              10038,\n",
       "              10436},\n",
       "             2021: {1841, 5948, 6918, 7952, 8425, 8466, 9626},\n",
       "             2227: {970, 1135, 5436, 5866, 7645, 8071},\n",
       "             2498: {1951, 2515, 2633, 9081, 10394, 10645, 10971},\n",
       "             870: {457, 2284, 5630, 8597, 9738, 10187, 11817},\n",
       "             320: {785, 5607, 6023, 6738, 9514, 11207, 13364},\n",
       "             262: {378, 2615, 2766, 4795, 6456, 6553, 11809, 12478, 12880},\n",
       "             1350: {2483, 3169, 4402, 5424, 8109, 10443},\n",
       "             1882: {473, 919, 1029, 4199, 5845, 6959, 10522},\n",
       "             595: {731, 1070, 2633, 2771, 4927, 7323},\n",
       "             2430: {3513, 4402, 5424, 10693, 10836, 10989},\n",
       "             1720: {772, 2551, 2898, 3629, 5690, 7793},\n",
       "             1825: {582, 668, 6229, 6302, 9681, 13362},\n",
       "             2635: {388, 888, 1088, 5579, 9512, 9955, 12620, 12782},\n",
       "             1423: {1472, 4205, 4589, 10422, 11289, 12788},\n",
       "             1234: {980,\n",
       "              2544,\n",
       "              3385,\n",
       "              4881,\n",
       "              5887,\n",
       "              6528,\n",
       "              7565,\n",
       "              9151,\n",
       "              9466,\n",
       "              13266},\n",
       "             2143: {959, 2170, 4988, 5599, 6050, 10347},\n",
       "             1940: {2170, 4988, 5138, 5599, 6050, 12818},\n",
       "             1809: {17, 3184, 7927, 8258, 10940, 12123},\n",
       "             923: {1033, 2031, 2322, 2950, 4931, 4993},\n",
       "             580: {2678, 4892, 5937, 10425, 10716, 12385},\n",
       "             939: {1118, 1866, 5663, 8594, 9235, 12893},\n",
       "             2274: {3778, 6001, 8226, 11322, 12636, 13296},\n",
       "             2342: {3564, 4789, 5332, 6515, 8032, 11243},\n",
       "             1500: {5250, 7310, 10135, 11376, 11873, 12185},\n",
       "             962: {3212,\n",
       "              3335,\n",
       "              3368,\n",
       "              6344,\n",
       "              7918,\n",
       "              8029,\n",
       "              9652,\n",
       "              9809,\n",
       "              11156,\n",
       "              11374},\n",
       "             3246: {1678, 2021, 5618, 8081, 11866, 11873},\n",
       "             2683: {617, 1366, 1951, 2329, 8456, 9555, 11155, 13306},\n",
       "             2048: {3417, 6972, 8859, 9003, 9146, 10661},\n",
       "             1664: {10,\n",
       "              731,\n",
       "              1413,\n",
       "              3123,\n",
       "              4148,\n",
       "              4988,\n",
       "              5298,\n",
       "              5624,\n",
       "              6050,\n",
       "              9007,\n",
       "              11515},\n",
       "             473: {10073, 10878, 11239, 11377, 11874, 12136},\n",
       "             2866: {86, 3231, 5200, 5459, 6474, 6730, 9014, 12092},\n",
       "             1380: {2515, 4503, 9555, 9681, 10971},\n",
       "             783: {1566, 3565, 6326, 6951, 11346, 11449},\n",
       "             2385: {4704, 5315, 6050, 6155, 7147, 7796, 9091},\n",
       "             2314: {271, 2376, 3968, 7863, 10584, 12879},\n",
       "             1476: {116, 1511, 2170, 4713, 4988, 5614, 10371},\n",
       "             2520: {298, 2756, 2778, 7202, 12111, 12872},\n",
       "             414: {4403, 6050, 6561, 7364, 9091, 9736},\n",
       "             1857: {362,\n",
       "              2267,\n",
       "              2762,\n",
       "              3110,\n",
       "              4737,\n",
       "              6365,\n",
       "              6519,\n",
       "              7704,\n",
       "              7984,\n",
       "              9300,\n",
       "              11213,\n",
       "              11515,\n",
       "              12717},\n",
       "             648: {159, 6456, 6655, 8520, 9285, 9695, 12860},\n",
       "             1038: {240,\n",
       "              551,\n",
       "              1435,\n",
       "              1782,\n",
       "              1892,\n",
       "              2261,\n",
       "              4064,\n",
       "              4718,\n",
       "              4827,\n",
       "              4891,\n",
       "              5354,\n",
       "              5423,\n",
       "              6650,\n",
       "              7267,\n",
       "              7416,\n",
       "              7486,\n",
       "              8503,\n",
       "              8606,\n",
       "              8892,\n",
       "              9002,\n",
       "              10149,\n",
       "              10310,\n",
       "              10826,\n",
       "              11495,\n",
       "              11711,\n",
       "              12030,\n",
       "              12710,\n",
       "              12801},\n",
       "             300: {131, 2369, 2975, 4047, 4695, 8444},\n",
       "             1356: {742, 4441, 6710, 7187, 8576, 13299, 13382},\n",
       "             518: {777, 1827, 2316, 7468, 9437, 11030},\n",
       "             47: {969, 3484, 4147, 5315, 7796, 7864, 8980, 9577},\n",
       "             2205: {450, 896, 1198, 1778, 4770, 9578},\n",
       "             1952: {165, 1078, 4880, 6424, 9652, 11836},\n",
       "             1445: {533, 4460, 4678, 6596, 7804, 9290, 12392},\n",
       "             1060: {1500, 6687, 8638, 8826, 11143, 11873},\n",
       "             899: {905, 2031, 2481, 8330, 10788, 11322},\n",
       "             1006: {4988, 6050, 7377, 7960, 8625, 12841},\n",
       "             1766: {282, 2192, 6918, 9515, 10206, 11322},\n",
       "             755: {2170, 4713, 4988, 5614, 6050, 9324},\n",
       "             2186: {2613, 3415, 4572, 5625, 7311, 9344},\n",
       "             3309: {1305, 3656, 3847, 9971, 10067, 12955},\n",
       "             2628: {950, 999, 2633, 6473, 10222, 12558},\n",
       "             1496: {4814, 5039, 5628, 6336, 11311, 11466},\n",
       "             54: {2170, 4988, 5599, 5614, 5675, 6050, 8508},\n",
       "             1260: {323,\n",
       "              1096,\n",
       "              1881,\n",
       "              2045,\n",
       "              2151,\n",
       "              3788,\n",
       "              5950,\n",
       "              6020,\n",
       "              6906,\n",
       "              7093,\n",
       "              7282,\n",
       "              7485,\n",
       "              7487,\n",
       "              8771,\n",
       "              9215,\n",
       "              10510,\n",
       "              11401,\n",
       "              11786,\n",
       "              12444,\n",
       "              12986},\n",
       "             1979: {2791, 3737, 4060, 4893, 9612, 11049},\n",
       "             2249: {1035, 2131, 4225, 8916, 10281, 12446},\n",
       "             277: {731,\n",
       "              2771,\n",
       "              4988,\n",
       "              6050,\n",
       "              9007,\n",
       "              10376,\n",
       "              11454,\n",
       "              11515,\n",
       "              12308,\n",
       "              12717},\n",
       "             761: {404, 1904, 2170, 4988, 5599, 5614, 6050, 8162, 9091},\n",
       "             1964: {404, 4988, 5207, 6050, 9091, 9705, 10347, 12637},\n",
       "             36: {2336, 8784, 9301, 10808, 11617, 12522, 12731},\n",
       "             724: {2483, 3169, 4402, 5424, 8636, 9596, 10164},\n",
       "             2929: {404, 3158, 5575, 9362, 9921, 10970, 11873, 12637},\n",
       "             393: {253, 2170, 4988, 5599, 5614, 6050, 7494, 9091},\n",
       "             2285: {54, 1078, 1951, 4351},\n",
       "             1714: {2483, 4402, 4825, 5424, 9596, 10164},\n",
       "             422: {279, 770, 950, 5298, 9681, 12774},\n",
       "             2707: {3169, 4402, 5424, 8636, 10164, 10836},\n",
       "             1850: {1778, 3108, 3417, 8859, 12814, 13196},\n",
       "             2940: {984, 3424, 4407, 6338, 6725, 10771},\n",
       "             2792: {555, 864, 3460, 5424, 8541, 8939, 9445, 9722},\n",
       "             1963: {598, 2183, 3469, 4332, 5784, 8399},\n",
       "             3268: {538,\n",
       "              2024,\n",
       "              3120,\n",
       "              3892,\n",
       "              4628,\n",
       "              4637,\n",
       "              6830,\n",
       "              7994,\n",
       "              9059,\n",
       "              9595,\n",
       "              9716,\n",
       "              13407},\n",
       "             492: {1127, 4303, 5233, 5307, 8791, 12985},\n",
       "             890: {478, 4851, 6505, 7090, 9794, 12066},\n",
       "             980: {16, 1222, 9468, 10788, 11322, 12575},\n",
       "             2366: {1266,\n",
       "              3566,\n",
       "              4780,\n",
       "              5893,\n",
       "              6708,\n",
       "              8411,\n",
       "              9265,\n",
       "              10024,\n",
       "              10651,\n",
       "              11046,\n",
       "              12500,\n",
       "              13311},\n",
       "             2102: {4063, 5086, 5758, 6050, 6696},\n",
       "             2029: {2483, 3513, 4402, 4825, 5424, 9596},\n",
       "             233: {470, 678, 986, 4988, 5331, 6005, 12045},\n",
       "             830: {2604, 3108, 3935, 6972, 8859, 9003, 10466},\n",
       "             3290: {48, 4364, 7947, 9081, 9789, 10354, 10526, 10645, 13085},\n",
       "             2776: {1406, 3717, 4499, 7193, 9238, 10566, 12819},\n",
       "             1565: {22,\n",
       "              2270,\n",
       "              2488,\n",
       "              5813,\n",
       "              5827,\n",
       "              6099,\n",
       "              6301,\n",
       "              7455,\n",
       "              9826,\n",
       "              10593,\n",
       "              10942,\n",
       "              11929},\n",
       "             1161: {2170,\n",
       "              4988,\n",
       "              5248,\n",
       "              5599,\n",
       "              5614,\n",
       "              6050,\n",
       "              8704,\n",
       "              9091,\n",
       "              12002,\n",
       "              13152},\n",
       "             217: {18, 5293, 9255, 9977, 10426, 11272},\n",
       "             2028: {3354, 6298, 6513, 9018, 11320, 13326},\n",
       "             144: {1923, 3536, 5315, 5474, 6202, 6765},\n",
       "             1471: {3108, 6972, 8859, 9003, 9146},\n",
       "             3283: {1779, 2507, 5699, 6107, 12818, 12902},\n",
       "             1525: {533, 2429, 5525, 5970, 9658, 10160, 12308, 12408, 12717},\n",
       "             431: {3472, 4453, 11333, 12197, 12648, 12981},\n",
       "             1392: {189, 1124, 3453, 3968, 4083, 7783, 7863, 9060, 13361},\n",
       "             21: {2785, 2993, 5281, 7941, 8806, 9793},\n",
       "             2523: {55,\n",
       "              457,\n",
       "              2284,\n",
       "              3874,\n",
       "              4111,\n",
       "              4777,\n",
       "              5630,\n",
       "              8597,\n",
       "              8840,\n",
       "              8847,\n",
       "              9730,\n",
       "              9759,\n",
       "              10187,\n",
       "              11144,\n",
       "              11817,\n",
       "              12072},\n",
       "             3327: {2314, 4432, 6217, 7663, 8933, 11463},\n",
       "             1748: {265, 607, 5424, 6022, 7002, 7198},\n",
       "             1703: {1458, 2515, 6424, 9366, 9759, 11508, 12924},\n",
       "             2318: {791, 967, 2339, 2824, 4737, 4988, 5143, 6050, 9091},\n",
       "             2047: {2133, 2899, 7204, 10028, 10373, 11873},\n",
       "             2057: {46, 213, 373, 3025, 3542, 12646},\n",
       "             1920: {3748, 4113, 7439, 9298, 9317, 13024},\n",
       "             748: {506, 778, 1406, 7439, 9186, 13013},\n",
       "             1151: {3433, 4402, 5424, 7354, 10443, 10610},\n",
       "             2734: {703, 1234, 11476, 11559, 12866},\n",
       "             1023: {1056, 2563, 4009, 7424, 9612, 9841, 11834},\n",
       "             3126: {1115,\n",
       "              1355,\n",
       "              1519,\n",
       "              4543,\n",
       "              5449,\n",
       "              7713,\n",
       "              10089,\n",
       "              11155,\n",
       "              11379,\n",
       "              11836},\n",
       "             1131: {2470, 4988, 5207, 6050, 9091, 12274, 12314},\n",
       "             201: {962, 3266, 4254, 5654, 7331, 7634},\n",
       "             2433: {691, 1826, 8080, 9091, 10745, 11777, 12680},\n",
       "             1040: {2740, 3417, 7816, 9791, 10412, 10466},\n",
       "             1851: {213, 5408, 6838, 10807, 13190, 13207},\n",
       "             1448: {82,\n",
       "              1527,\n",
       "              2000,\n",
       "              2858,\n",
       "              5646,\n",
       "              6995,\n",
       "              7589,\n",
       "              7837,\n",
       "              9425,\n",
       "              11122,\n",
       "              11570,\n",
       "              13089},\n",
       "             1311: {349, 3570, 5019, 5374, 8286, 11459, 12638},\n",
       "             601: {1070, 2771, 2791, 5624, 7713, 12308},\n",
       "             2148: {169, 3317, 5336, 9424, 9681, 11156, 13303},\n",
       "             965: {1789, 3175, 4201, 4574, 11759, 12983},\n",
       "             1477: {656, 4906, 5617, 7632, 8528, 12798},\n",
       "             945: {3513, 4402, 4825, 5424, 9429, 9596},\n",
       "             161: {1842, 3315, 7346, 8921, 11407},\n",
       "             1005: {293, 1078, 4565, 5035, 7412, 10159, 12332},\n",
       "             1758: {2937, 3678, 3887, 4187, 7024, 9617, 12214},\n",
       "             1082: {877, 6227, 6728, 8207, 10467, 13037},\n",
       "             820: {2483, 4402, 5424, 6847, 9596, 10254},\n",
       "             34: {2354, 5031, 5724, 8379, 10380, 11910},\n",
       "             1283: {1629,\n",
       "              2193,\n",
       "              6875,\n",
       "              7746,\n",
       "              7842,\n",
       "              8043,\n",
       "              8412,\n",
       "              10976,\n",
       "              11628,\n",
       "              11681,\n",
       "              12414,\n",
       "              12564},\n",
       "             3132: {2170, 4988, 5599, 5614, 6050, 12818},\n",
       "             1665: {3751, 5854, 7857, 9174, 9656, 12580, 13239},\n",
       "             38: {312, 3513, 5424, 11872, 12818},\n",
       "             388: {489, 950, 2329, 2515, 7891, 8377},\n",
       "             1853: {404, 1541, 2170, 4988, 6050, 12336, 12973},\n",
       "             596: {1826, 4297, 6075, 8223, 9091, 10185, 10307},\n",
       "             1636: {163, 1144, 4783, 7971, 9055},\n",
       "             23: {159, 4017, 4265, 5479, 5506, 8520, 9695},\n",
       "             2313: {868, 2007, 3513, 6917, 10041, 11872},\n",
       "             2351: {5424, 6022, 6847, 7198, 9596, 10164},\n",
       "             3320: {427, 3453, 3968, 5300, 6706, 7863, 9011, 10584, 12142},\n",
       "             2447: {1735, 2013, 3638, 4527, 7316, 10928},\n",
       "             3067: {1539, 3375, 6520, 8464, 10120},\n",
       "             660: {6523, 7035, 8667, 9850, 10844, 10987},\n",
       "             671: {3677, 4402, 4825, 5998, 10443, 11988},\n",
       "             1600: {892, 1285, 1932, 2711, 3252, 11774},\n",
       "             2855: {3016, 5365, 7503, 8858, 9116, 12236},\n",
       "             125: {2624, 6074, 7031, 8048, 9402, 13060},\n",
       "             3127: {1113,\n",
       "              1624,\n",
       "              3990,\n",
       "              4403,\n",
       "              5841,\n",
       "              6050,\n",
       "              7356,\n",
       "              7958,\n",
       "              9901,\n",
       "              12217,\n",
       "              12237,\n",
       "              12591,\n",
       "              13291},\n",
       "             471: {2483, 4402, 5424, 6847, 7198, 9596},\n",
       "             2175: {1526, 2578, 3370, 4146, 5624, 11281, 13038},\n",
       "             2164: {959, 3509, 5113, 5607, 5933, 8989, 11873},\n",
       "             2982: {936, 1387, 3134, 3497, 3961, 5898},\n",
       "             2072: {2771, 2943, 2955, 5037, 5420, 7387, 9080, 12308, 12402},\n",
       "             790: {1821, 3324, 3326, 5165, 7664, 12907},\n",
       "             1472: {81, 4796, 7789, 8809, 10526, 12504},\n",
       "             127: {4402, 5424, 5545, 6022, 9429, 10164},\n",
       "             2446: {4099, 6158, 9814, 11321, 12610, 13072},\n",
       "             621: {1861,\n",
       "              5261,\n",
       "              5518,\n",
       "              5980,\n",
       "              7278,\n",
       "              7574,\n",
       "              8473,\n",
       "              8655,\n",
       "              8991,\n",
       "              9283,\n",
       "              11385,\n",
       "              12068},\n",
       "             3057: {7878, 8210, 8745, 10268, 10362, 12733},\n",
       "             2408: {2483, 3169, 4402, 4825, 5424, 7198, 10164},\n",
       "             3225: {731, 2165, 2771, 3119, 4988, 9007, 12308},\n",
       "             920: {963, 1245, 4547, 5108, 6142, 11364},\n",
       "             1810: {607, 2483, 3513, 4402, 5424, 9596},\n",
       "             1193: {3609, 3832, 5201, 5897, 8401, 12896},\n",
       "             2926: {2715, 2933, 3499, 11830},\n",
       "             712: {1749, 3134, 7684, 9515, 12317, 13180},\n",
       "             3273: {731, 1516, 2955, 4611, 7821, 8689, 8809},\n",
       "             999: {1524, 3048, 3795, 4203, 5264, 7258, 8613, 11215},\n",
       "             1224: {1764, 4627, 4800, 5063, 8284, 12509},\n",
       "             1544: {2445, 5551, 6461, 7259, 7361, 8244},\n",
       "             1861: {450, 3108, 3935, 8859, 9003, 9146, 9828},\n",
       "             911: {2860, 6668, 8022, 8033, 9627, 10163, 11024},\n",
       "             2981: {2091, 5392, 6228, 11292, 12357, 12882},\n",
       "             2646: {2520, 6226, 7970, 10665, 11065, 11414},\n",
       "             1833: {2141, 3403, 6916, 9728, 9826, 11737},\n",
       "             1727: {29, 777, 1892, 2855, 3213, 5423, 7796, 9918, 10204, 13005},\n",
       "             1818: {118, 1951, 2291, 4499, 4761, 6302, 12991},\n",
       "             1069: {1405, 2165, 2955, 8084, 8232, 9103, 10227},\n",
       "             1156: {1679, 1738, 2492, 3057, 5184, 5916, 7452, 7958, 9290},\n",
       "             2257: {1280,\n",
       "              2473,\n",
       "              3549,\n",
       "              3960,\n",
       "              4383,\n",
       "              6050,\n",
       "              6880,\n",
       "              7147,\n",
       "              7558,\n",
       "              7769,\n",
       "              9019,\n",
       "              9081,\n",
       "              10636,\n",
       "              11155,\n",
       "              11553,\n",
       "              11738,\n",
       "              11950},\n",
       "             3307: {4402, 5424, 7198, 10164, 10443, 10693},\n",
       "             1171: {1196, 3300, 5779, 9692, 12388},\n",
       "             2283: {2483, 3262, 4402, 5424, 7198, 10164, 10254},\n",
       "             69: {1162, 1951, 7646, 8456, 9081, 12340},\n",
       "             3145: {1488,\n",
       "              2062,\n",
       "              6111,\n",
       "              6857,\n",
       "              8045,\n",
       "              8172,\n",
       "              8584,\n",
       "              11430,\n",
       "              11982,\n",
       "              13375},\n",
       "             2597: {946, 1494, 2044, 2159, 3001, 8035, 8351, 12143, 13026},\n",
       "             496: {4988, 5466, 6050, 9091, 10912, 11515, 11819, 12717},\n",
       "             2590: {5424, 7198, 8636, 9429, 10164, 10836, 13300},\n",
       "             2576: {163, 1565, 4151, 7151, 7201, 9829},\n",
       "             3261: {1961, 6138, 8863, 10115, 12972, 13202},\n",
       "             136: {3155, 4334, 4481, 7791, 12161},\n",
       "             2233: {3665, 5316, 6103, 8106, 8904, 11533},\n",
       "             2820: {678, 3167, 3834, 6910, 8719, 12274, 12559},\n",
       "             1037: {2483, 4402, 4825, 5424, 6031, 10164},\n",
       "             2355: {363, 404, 2170, 4056, 4988, 6468, 9609},\n",
       "             55: {492, 1981, 3051, 5814, 6050, 11116, 11825, 11833},\n",
       "             3180: {2997, 7408, 8287, 8293, 10419, 10963, 11001, 12233},\n",
       "             2140: {868, 2483, 3262, 3677, 4402, 6917},\n",
       "             1961: {764, 6953, 8295, 8458},\n",
       "             ...})"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "eventsForUser"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "pickle.dump(userIndex,open(\"userIndex.pkl\",'wb'))\n",
    "pickle.dump(eventIndex,open(\"eventIndex.pkl\",'wb'))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "uniqueUserPairs = set()\n",
    "uniqueEventPairs = set()\n",
    "for event in uniqueEvents:\n",
    "    i = eventIndex[event]\n",
    "    users = usersForEvent[i]\n",
    "    if len(users)>2:\n",
    "        uniqueUserPairs.update(itertools.combinations(users,2))\n",
    "\n",
    "for user in uniqueUsers:\n",
    "    u = userIndex[user]\n",
    "    events = eventsForUser[u]\n",
    "    if len(events)>2:\n",
    "        uniqueEventPairs.update(itertools.combinations(events,2))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{(3112, 1401),\n",
       " (2430, 940),\n",
       " (898, 1148),\n",
       " (146, 761),\n",
       " (1836, 238),\n",
       " (53, 1729),\n",
       " (2434, 2805),\n",
       " (132, 420),\n",
       " (5, 178),\n",
       " (1432, 2544),\n",
       " (1967, 1344),\n",
       " (178, 3366),\n",
       " (3296, 3173),\n",
       " (1713, 1270),\n",
       " (3153, 1964),\n",
       " (2130, 2175),\n",
       " (1049, 853),\n",
       " (2567, 1128),\n",
       " (1339, 2435),\n",
       " (3042, 2545),\n",
       " (1982, 3323),\n",
       " (1704, 2019),\n",
       " (51, 2281),\n",
       " (2104, 3186),\n",
       " (119, 2545),\n",
       " (3372, 1325),\n",
       " (1492, 2654),\n",
       " (2685, 2368),\n",
       " (1599, 1690),\n",
       " (1196, 883),\n",
       " (2664, 3178),\n",
       " (899, 747),\n",
       " (3132, 1921),\n",
       " (1369, 417),\n",
       " (27, 420),\n",
       " (2636, 3312),\n",
       " (2106, 2151),\n",
       " (2620, 2797),\n",
       " (359, 971),\n",
       " (2707, 3338),\n",
       " (340, 1393),\n",
       " (1064, 1797),\n",
       " (670, 350),\n",
       " (1853, 847),\n",
       " (2896, 1457),\n",
       " (3300, 1119),\n",
       " (1380, 103),\n",
       " (1253, 255),\n",
       " (1062, 2283),\n",
       " (2341, 2929),\n",
       " (414, 1143),\n",
       " (708, 2896),\n",
       " (3230, 1457),\n",
       " (3124, 3292),\n",
       " (2755, 595),\n",
       " (5, 374),\n",
       " (1146, 1520),\n",
       " (2764, 3299),\n",
       " (1810, 1345),\n",
       " (2854, 3173),\n",
       " (24, 2984),\n",
       " (2805, 277),\n",
       " (420, 819),\n",
       " (1157, 2854),\n",
       " (1109, 257),\n",
       " (1554, 398),\n",
       " (2454, 2223),\n",
       " (549, 2286),\n",
       " (2676, 1866),\n",
       " (180, 1351),\n",
       " (11, 3130),\n",
       " (1039, 2310),\n",
       " (2797, 3005),\n",
       " (3218, 2911),\n",
       " (1554, 2165),\n",
       " (1425, 1967),\n",
       " (3111, 1748),\n",
       " (2676, 3373),\n",
       " (1131, 1418),\n",
       " (3372, 2516),\n",
       " (1293, 459),\n",
       " (27, 992),\n",
       " (3104, 1134),\n",
       " (1094, 761),\n",
       " (942, 378),\n",
       " (1539, 540),\n",
       " (1647, 487),\n",
       " (1405, 984),\n",
       " (2984, 1084),\n",
       " (303, 708),\n",
       " (1850, 839),\n",
       " (1027, 1840),\n",
       " (3378, 3028),\n",
       " (940, 2883),\n",
       " (2165, 1261),\n",
       " (575, 1084),\n",
       " (1891, 1765),\n",
       " (1292, 660),\n",
       " (3366, 1917),\n",
       " (1027, 2221),\n",
       " (176, 708),\n",
       " (1797, 1457),\n",
       " (729, 408),\n",
       " (1580, 1095),\n",
       " (796, 971),\n",
       " (2724, 2894),\n",
       " (1393, 897),\n",
       " (538, 3042),\n",
       " (789, 1662),\n",
       " (3375, 1921),\n",
       " (3107, 1875),\n",
       " (2219, 2318),\n",
       " (411, 1992),\n",
       " (615, 2664),\n",
       " (2703, 2768),\n",
       " (1438, 2797),\n",
       " (1084, 1977),\n",
       " (3374, 1439),\n",
       " (1233, 1001),\n",
       " (1418, 1489),\n",
       " (44, 2094),\n",
       " (560, 553),\n",
       " (2006, 2904),\n",
       " (784, 2557),\n",
       " (1595, 755),\n",
       " (3346, 1476),\n",
       " (1332, 971),\n",
       " (1062, 1748),\n",
       " (417, 456),\n",
       " (391, 2547),\n",
       " (1747, 940),\n",
       " (1599, 951),\n",
       " (613, 2368),\n",
       " (3228, 1824),\n",
       " (2179, 1853),\n",
       " (705, 1949),\n",
       " (2187, 2894),\n",
       " (2313, 499),\n",
       " (230, 1936),\n",
       " (3203, 1998),\n",
       " (1888, 2434),\n",
       " (1539, 984),\n",
       " (1872, 230),\n",
       " (3387, 897),\n",
       " (1151, 2408),\n",
       " (2237, 1960),\n",
       " (515, 416),\n",
       " (3378, 3352),\n",
       " (2469, 1580),\n",
       " (663, 2844),\n",
       " (61, 1130),\n",
       " (720, 3042),\n",
       " (24, 325),\n",
       " (2059, 1148),\n",
       " (1095, 2385),\n",
       " (1068, 439),\n",
       " (2956, 2921),\n",
       " (53, 1426),\n",
       " (1146, 1551),\n",
       " (833, 866),\n",
       " (809, 2496),\n",
       " (1575, 1408),\n",
       " (2266, 2875),\n",
       " (16, 616),\n",
       " (1339, 1872),\n",
       " (1035, 919),\n",
       " (2569, 2256),\n",
       " (915, 1368),\n",
       " (2676, 2725),\n",
       " (686, 2281),\n",
       " (3282, 1246),\n",
       " (1096, 3375),\n",
       " (3178, 1439),\n",
       " (2685, 2961),\n",
       " (2894, 1532),\n",
       " (1818, 2286),\n",
       " (552, 2317),\n",
       " (1765, 2911),\n",
       " (1071, 1954),\n",
       " (2073, 3230),\n",
       " (320, 889),\n",
       " (607, 2857),\n",
       " (193, 1773),\n",
       " (2283, 905),\n",
       " (905, 1507),\n",
       " (1180, 2434),\n",
       " (1431, 1134),\n",
       " (2451, 793),\n",
       " (705, 2854),\n",
       " (146, 2953),\n",
       " (1377, 3047),\n",
       " (538, 1415),\n",
       " (575, 180),\n",
       " (2792, 1425),\n",
       " (1977, 476),\n",
       " (928, 471),\n",
       " (3186, 705),\n",
       " (1781, 1838),\n",
       " (3299, 418),\n",
       " (616, 1647),\n",
       " (492, 494),\n",
       " (61, 2995),\n",
       " (1157, 3186),\n",
       " (1360, 3202),\n",
       " (586, 1838),\n",
       " (615, 2544),\n",
       " (784, 1946),\n",
       " (357, 2496),\n",
       " (1657, 972),\n",
       " (148, 1285),\n",
       " (1261, 3346),\n",
       " (1157, 1495),\n",
       " (1196, 2435),\n",
       " (761, 828),\n",
       " (613, 803),\n",
       " (1180, 1816),\n",
       " (1583, 2673),\n",
       " (2560, 1109),\n",
       " (1097, 1006),\n",
       " (3079, 1946),\n",
       " (1701, 1258),\n",
       " (2911, 1426),\n",
       " (1062, 1372),\n",
       " (2267, 1391),\n",
       " (3228, 2984),\n",
       " (408, 1049),\n",
       " (1071, 1510),\n",
       " (728, 418),\n",
       " (195, 999),\n",
       " (2624, 311),\n",
       " (2073, 55),\n",
       " (2904, 3327),\n",
       " (1253, 868),\n",
       " (386, 1532),\n",
       " (905, 340),\n",
       " (391, 1857),\n",
       " (1647, 180),\n",
       " (2407, 1964),\n",
       " (3094, 172),\n",
       " (2582, 496),\n",
       " (2266, 1372),\n",
       " (3373, 411),\n",
       " (1380, 2573),\n",
       " (2764, 1523),\n",
       " (1891, 1490),\n",
       " (2273, 456),\n",
       " (1838, 3247),\n",
       " (148, 3366),\n",
       " (1285, 1977),\n",
       " (831, 1399),\n",
       " (1538, 1339),\n",
       " (1955, 2469),\n",
       " (3127, 3332),\n",
       " (632, 1436),\n",
       " (1697, 410),\n",
       " (761, 376),\n",
       " (2102, 2480),\n",
       " (2724, 720),\n",
       " (615, 1369),\n",
       " (2560, 2961),\n",
       " (3079, 350),\n",
       " (2853, 1332),\n",
       " (2526, 1520),\n",
       " (2219, 408),\n",
       " (2685, 1817),\n",
       " (1447, 2902),\n",
       " (2627, 295),\n",
       " (3106, 1700),\n",
       " (1664, 636),\n",
       " (686, 1532),\n",
       " (2225, 2547),\n",
       " (1737, 2894),\n",
       " (1539, 3372),\n",
       " (50, 54),\n",
       " (2707, 2899),\n",
       " (1687, 1936),\n",
       " (356, 2771),\n",
       " (2089, 1128),\n",
       " (2221, 3247),\n",
       " (2345, 3318),\n",
       " (1966, 601),\n",
       " (25, 2104),\n",
       " (2904, 2619),\n",
       " (1186, 1379),\n",
       " (2153, 2129),\n",
       " (1048, 1196),\n",
       " (1702, 2907),\n",
       " (1834, 311),\n",
       " (2896, 467),\n",
       " (663, 2797),\n",
       " (538, 146),\n",
       " (2220, 917),\n",
       " (1128, 1710),\n",
       " (1086, 2252),\n",
       " (259, 1967),\n",
       " (2116, 710),\n",
       " (1064, 2434),\n",
       " (2582, 1115),\n",
       " (531, 1095),\n",
       " (88, 411),\n",
       " (2125, 784),\n",
       " (439, 3042),\n",
       " (2805, 1246),\n",
       " (2318, 2557),\n",
       " (2837, 595),\n",
       " (2842, 1327),\n",
       " (540, 3346),\n",
       " (1402, 1499),\n",
       " (761, 1489),\n",
       " (2685, 1373),\n",
       " (1599, 2695),\n",
       " (2150, 1992),\n",
       " (1332, 862),\n",
       " (338, 2266),\n",
       " (1062, 1603),\n",
       " (1276, 2984),\n",
       " (883, 1954),\n",
       " (3104, 1701),\n",
       " (1447, 1087),\n",
       " (1710, 1967),\n",
       " (2221, 883),\n",
       " (3228, 1723),\n",
       " (3373, 3006),\n",
       " (1253, 1276),\n",
       " (2200, 951),\n",
       " (705, 1258),\n",
       " (1094, 304),\n",
       " (607, 2526),\n",
       " (2172, 1971),\n",
       " (3203, 1723),\n",
       " (1332, 1457),\n",
       " (1426, 1910),\n",
       " (176, 2832),\n",
       " (2237, 1853),\n",
       " (1219, 2285),\n",
       " (260, 2408),\n",
       " (1952, 3086),\n",
       " (1603, 3146),\n",
       " (609, 2094),\n",
       " (386, 1739),\n",
       " (1368, 537),\n",
       " (2725, 308),\n",
       " (2054, 1068),\n",
       " (538, 3373),\n",
       " (612, 2434),\n",
       " (2792, 3387),\n",
       " (459, 1808),\n",
       " (3299, 2316),\n",
       " (1762, 2844),\n",
       " (2838, 2200),\n",
       " (1960, 972),\n",
       " (1664, 3225),\n",
       " (3132, 3005),\n",
       " (2676, 853),\n",
       " (0, 248),\n",
       " (1060, 889),\n",
       " (1335, 2012),\n",
       " (2365, 2634),\n",
       " (1697, 687),\n",
       " (777, 784),\n",
       " (3307, 1345),\n",
       " (1425, 940),\n",
       " (1134, 462),\n",
       " (1835, 601),\n",
       " (1146, 2764),\n",
       " (2052, 2300),\n",
       " (1595, 1749),\n",
       " (1192, 3372),\n",
       " (2832, 868),\n",
       " (2172, 1399),\n",
       " (119, 252),\n",
       " (942, 1401),\n",
       " (2857, 311),\n",
       " (1431, 2019),\n",
       " (1749, 868),\n",
       " (1551, 2310),\n",
       " (951, 1781),\n",
       " (522, 951),\n",
       " (3019, 3023),\n",
       " (1737, 408),\n",
       " (2728, 2544),\n",
       " (1408, 2664),\n",
       " (391, 1142),\n",
       " (513, 1332),\n",
       " (1702, 3150),\n",
       " (2351, 2961),\n",
       " (194, 2832),\n",
       " (3322, 148),\n",
       " (2054, 616),\n",
       " (1128, 897),\n",
       " (1157, 3303),\n",
       " (279, 1449),\n",
       " (1580, 2725),\n",
       " (2102, 868),\n",
       " (90, 260),\n",
       " (1418, 476),\n",
       " (1159, 2434),\n",
       " (1810, 586),\n",
       " (3079, 1551),\n",
       " (1205, 2368),\n",
       " (2484, 1272),\n",
       " (929, 761),\n",
       " (1586, 1253),\n",
       " (255, 2959),\n",
       " (1134, 1697),\n",
       " (1039, 61),\n",
       " (3079, 2544),\n",
       " (66, 940),\n",
       " (3173, 705),\n",
       " (2150, 3354),\n",
       " (885, 2125),\n",
       " (1934, 2294),\n",
       " (538, 1998),\n",
       " (3092, 601),\n",
       " (2797, 1325),\n",
       " (1276, 350),\n",
       " (1096, 1964),\n",
       " (3385, 1489),\n",
       " (3300, 3048),\n",
       " (2190, 3129),\n",
       " (1463, 1910),\n",
       " (411, 2988),\n",
       " (2054, 180),\n",
       " (612, 3354),\n",
       " (522, 1134),\n",
       " (127, 2518),\n",
       " (2423, 975),\n",
       " (1233, 853),\n",
       " (1838, 3130),\n",
       " (3214, 3116),\n",
       " (2969, 2190),\n",
       " (2351, 1134),\n",
       " (2467, 2865),\n",
       " (784, 1489),\n",
       " (2257, 2469),\n",
       " (1049, 1131),\n",
       " (277, 416),\n",
       " (994, 146),\n",
       " (1143, 2219),\n",
       " (1261, 304),\n",
       " (530, 1872),\n",
       " (1872, 987),\n",
       " (2911, 987),\n",
       " (1094, 3225),\n",
       " (728, 2318),\n",
       " (3079, 467),\n",
       " (1074, 277),\n",
       " (54, 3178),\n",
       " (38, 2351),\n",
       " (2200, 2283),\n",
       " (408, 416),\n",
       " (2959, 369),\n",
       " (1170, 2092),\n",
       " (1233, 1276),\n",
       " (2685, 3379),\n",
       " (2187, 2984),\n",
       " (2894, 862),\n",
       " (885, 2433),\n",
       " (1129, 1315),\n",
       " (951, 2685),\n",
       " (940, 710),\n",
       " (1936, 471),\n",
       " (728, 1476),\n",
       " (3090, 1723),\n",
       " (50, 2768),\n",
       " (988, 1655),\n",
       " (1186, 1526),\n",
       " (1064, 146),\n",
       " (1829, 2368),\n",
       " (1027, 38),\n",
       " (3090, 2334),\n",
       " (2568, 1797),\n",
       " (612, 862),\n",
       " (53, 2899),\n",
       " (1128, 1817),\n",
       " (148, 2797),\n",
       " (2707, 1810),\n",
       " (3303, 2883),\n",
       " (3186, 1891),\n",
       " (1027, 2435),\n",
       " (513, 2073),\n",
       " (1921, 3322),\n",
       " (597, 2838),\n",
       " (2072, 1583),\n",
       " (1605, 398),\n",
       " (1697, 1875),\n",
       " (2664, 1917),\n",
       " (809, 2430),\n",
       " (1575, 1130),\n",
       " (1810, 1746),\n",
       " (1116, 333),\n",
       " (2865, 854),\n",
       " (1664, 2984),\n",
       " (694, 287),\n",
       " (784, 376),\n",
       " (113, 1426),\n",
       " (2567, 1603),\n",
       " (55, 467),\n",
       " (2685, 1490),\n",
       " (2203, 500),\n",
       " (1418, 1739),\n",
       " (2187, 971),\n",
       " (1614, 2899),\n",
       " (1261, 1497),\n",
       " (2223, 1749),\n",
       " (2832, 1192),\n",
       " (16, 1405),\n",
       " (1690, 1891),\n",
       " (119, 2984),\n",
       " (709, 2158),\n",
       " (2707, 2200),\n",
       " (1647, 2844),\n",
       " (391, 2265),\n",
       " (2883, 3027),\n",
       " (705, 1383),\n",
       " (977, 506),\n",
       " (744, 411),\n",
       " (1062, 3173),\n",
       " (2728, 708),\n",
       " (1426, 2029),\n",
       " (3373, 1432),\n",
       " (3090, 3042),\n",
       " (755, 61),\n",
       " (2252, 2266),\n",
       " (2125, 2724),\n",
       " (522, 230),\n",
       " (185, 2995),\n",
       " (2357, 3005),\n",
       " (2672, 929),\n",
       " (1557, 830),\n",
       " (2849, 2408),\n",
       " (2430, 945),\n",
       " (1580, 369),\n",
       " (1027, 2911),\n",
       " (3186, 295),\n",
       " (2568, 252),\n",
       " (2725, 185),\n",
       " (2257, 3373),\n",
       " (1748, 975),\n",
       " (259, 945),\n",
       " (581, 2997),\n",
       " (1967, 687),\n",
       " (3107, 1157),\n",
       " (1541, 3006),\n",
       " (1575, 686),\n",
       " (3299, 2745),\n",
       " (710, 1350),\n",
       " (32, 1977),\n",
       " (1664, 3092),\n",
       " (2805, 252),\n",
       " (2676, 984),\n",
       " (1678, 929),\n",
       " (1095, 1285),\n",
       " (3296, 1765),\n",
       " (2724, 374),\n",
       " (2408, 1490),\n",
       " (3111, 586),\n",
       " (1701, 1344),\n",
       " (2798, 1135),\n",
       " (2673, 602),\n",
       " (327, 503),\n",
       " (184, 127),\n",
       " (1267, 1992),\n",
       " (398, 1739),\n",
       " (2424, 456),\n",
       " (1380, 1577),\n",
       " (2516, 408),\n",
       " (66, 127),\n",
       " (1064, 1834),\n",
       " (308, 416),\n",
       " (2110, 3324),\n",
       " (1449, 2000),\n",
       " (575, 418),\n",
       " (1062, 2252),\n",
       " (1186, 1797),\n",
       " (2116, 1729),\n",
       " (854, 127),\n",
       " (88, 1438),\n",
       " (2329, 2512),\n",
       " (3112, 53),\n",
       " (2836, 2433),\n",
       " (708, 720),\n",
       " (2573, 3314),\n",
       " (2125, 434),\n",
       " (2805, 304),\n",
       " (2143, 1977),\n",
       " (960, 2153),\n",
       " (662, 1437),\n",
       " (3379, 1729),\n",
       " (830, 839),\n",
       " (1217, 1662),\n",
       " (1580, 3203),\n",
       " (671, 1345),\n",
       " (597, 184),\n",
       " (500, 1850),\n",
       " (2560, 2875),\n",
       " (3153, 744),\n",
       " (230, 3303),\n",
       " (66, 2140),\n",
       " (3079, 1664),\n",
       " (113, 1671),\n",
       " (50, 1657),\n",
       " (1599, 1829),\n",
       " (1365, 2423),\n",
       " (885, 1917),\n",
       " (1325, 1520),\n",
       " (260, 1008),\n",
       " (2856, 3017),\n",
       " (3127, 148),\n",
       " (2832, 411),\n",
       " (2345, 2743),\n",
       " (2578, 1203),\n",
       " (3372, 2545),\n",
       " (1408, 1476),\n",
       " (2596, 2104),\n",
       " (2910, 868),\n",
       " (3199, 3230),\n",
       " (1765, 1954),\n",
       " (552, 1690),\n",
       " (1449, 2476),\n",
       " (1457, 2545),\n",
       " (1799, 2484),\n",
       " (25, 2518),\n",
       " (61, 252),\n",
       " (1383, 2423),\n",
       " (3090, 1130),\n",
       " (2073, 777),\n",
       " (1186, 1737),\n",
       " (3173, 2283),\n",
       " (2273, 2357),\n",
       " (213, 929),\n",
       " (2836, 418),\n",
       " (1686, 1050),\n",
       " (942, 351),\n",
       " (2695, 409),\n",
       " (2568, 1140),\n",
       " (538, 296),\n",
       " (2125, 2385),\n",
       " (2469, 1523),\n",
       " (3115, 2222),\n",
       " (2317, 1875),\n",
       " (1151, 340),\n",
       " (176, 729),\n",
       " (1739, 88),\n",
       " (2329, 439),\n",
       " (967, 1885),\n",
       " (2054, 1678),\n",
       " (538, 2959),\n",
       " (2487, 755),\n",
       " (386, 2480),\n",
       " (2143, 1405),\n",
       " (2842, 1006),\n",
       " (2510, 528),\n",
       " (1671, 2575),\n",
       " (3105, 728),\n",
       " (1435, 2487),\n",
       " (1710, 3027),\n",
       " (376, 496),\n",
       " (3153, 180),\n",
       " (1039, 2273),\n",
       " (744, 2676),\n",
       " (670, 2844),\n",
       " (643, 2044),\n",
       " (3374, 1408),\n",
       " (1625, 386),\n",
       " (1678, 180),\n",
       " (1982, 2547),\n",
       " (1614, 2658),\n",
       " (1148, 1069),\n",
       " (41, 530),\n",
       " (1452, 2266),\n",
       " (295, 2266),\n",
       " (2187, 2853),\n",
       " (1415, 411),\n",
       " (1603, 2955),\n",
       " (1151, 2423),\n",
       " (3228, 416),\n",
       " (2200, 1196),\n",
       " (2073, 1186),\n",
       " (1746, 1365),\n",
       " (1140, 296),\n",
       " (1011, 500),\n",
       " (1379, 2424),\n",
       " (132, 1181),\n",
       " (3115, 2922),\n",
       " (70, 1949),\n",
       " (819, 1021),\n",
       " (1116, 2685),\n",
       " (252, 2000),\n",
       " (1285, 972),\n",
       " (1052, 3017),\n",
       " (1049, 1580),\n",
       " (2628, 3323),\n",
       " (388, 666),\n",
       " (1964, 3167),\n",
       " (2219, 2273),\n",
       " (3379, 1401),\n",
       " (1575, 1439),\n",
       " (194, 601),\n",
       " (687, 1714),\n",
       " (1762, 2786),\n",
       " (279, 847),\n",
       " (434, 1992),\n",
       " (1192, 496),\n",
       " (193, 2910),\n",
       " (1049, 393),\n",
       " (1157, 1086),\n",
       " (184, 3379),\n",
       " (2203, 65),\n",
       " (1625, 1662),\n",
       " (3355, 3124),\n",
       " (3225, 2724),\n",
       " (2885, 1425),\n",
       " (2853, 391),\n",
       " (2768, 1405),\n",
       " (1888, 408),\n",
       " (820, 1344),\n",
       " (2150, 2329),\n",
       " (255, 1325),\n",
       " (560, 1781),\n",
       " (1103, 2951),\n",
       " (2329, 1327),\n",
       " (3230, 2355),\n",
       " (304, 1459),\n",
       " (1276, 1369),\n",
       " (2283, 940),\n",
       " (820, 987),\n",
       " (335, 2961),\n",
       " (3366, 2355),\n",
       " (2322, 736),\n",
       " (928, 2849),\n",
       " (1151, 2955),\n",
       " (54, 279),\n",
       " (1064, 1625),\n",
       " (398, 369),\n",
       " (2728, 847),\n",
       " (2988, 3117),\n",
       " (1327, 1940),\n",
       " (1463, 883),\n",
       " (1128, 1344),\n",
       " (1737, 374),\n",
       " (524, 1747),\n",
       " (2317, 987),\n",
       " (176, 417),\n",
       " (3299, 393),\n",
       " (1181, 303),\n",
       " (897, 2283),\n",
       " (2838, 1954),\n",
       " (1261, 3373),\n",
       " (2487, 476),\n",
       " (2471, 2043),\n",
       " (3073, 2491),\n",
       " (1697, 945),\n",
       " (933, 3150),\n",
       " (1095, 1662),\n",
       " (2703, 1992),\n",
       " (784, 3354),\n",
       " (3095, 474),\n",
       " (180, 1971),\n",
       " (267, 1368),\n",
       " (50, 1192),\n",
       " (3203, 2544),\n",
       " (744, 2407),\n",
       " (1360, 109),\n",
       " (2664, 3322),\n",
       " (1554, 2497),\n",
       " (2055, 265),\n",
       " (2089, 2266),\n",
       " (391, 2582),\n",
       " (1551, 1723),\n",
       " (1625, 663),\n",
       " (2104, 2685),\n",
       " (1180, 408),\n",
       " (1131, 1246),\n",
       " (1291, 1325),\n",
       " (2735, 475),\n",
       " (1062, 988),\n",
       " (1155, 2454),\n",
       " (2496, 3303),\n",
       " (41, 2300),\n",
       " (1327, 456),\n",
       " (2861, 2813),\n",
       " (24, 1762),\n",
       " (1875, 2435),\n",
       " (1276, 416),\n",
       " (232, 1361),\n",
       " (1971, 1049),\n",
       " (3112, 2885),\n",
       " (337, 2769),\n",
       " (2266, 1401),\n",
       " (531, 213),\n",
       " (1161, 1946),\n",
       " (2165, 1369),\n",
       " (2112, 2907),\n",
       " (992, 3087),\n",
       " (2683, 1272),\n",
       " (2614, 1850),\n",
       " (3096, 549),\n",
       " (2658, 1258),\n",
       " (2560, 3115),\n",
       " (2573, 3175),\n",
       " (55, 3372),\n",
       " (1130, 1408),\n",
       " (1344, 2883),\n",
       " (1217, 1739),\n",
       " (279, 88),\n",
       " (615, 1332),\n",
       " (1595, 3354),\n",
       " (2961, 801),\n",
       " (184, 710),\n",
       " (3104, 3379),\n",
       " (1599, 2222),\n",
       " (2883, 2004),\n",
       " (2221, 1765),\n",
       " (615, 729),\n",
       " (1351, 1977),\n",
       " (2334, 1948),\n",
       " (2413, 2129),\n",
       " (32, 3366),\n",
       " (744, 1438),\n",
       " (175, 2620),\n",
       " (2341, 992),\n",
       " (1124, 929),\n",
       " (2205, 1861),\n",
       " (61, 369),\n",
       " (1094, 777),\n",
       " (3173, 1936),\n",
       " (1124, 1476),\n",
       " (2073, 1523),\n",
       " (3288, 1050),\n",
       " (940, 3027),\n",
       " (2054, 414),\n",
       " (127, 2252),\n",
       " (340, 3027),\n",
       " (3112, 2044),\n",
       " (2764, 311),\n",
       " (416, 1955),\n",
       " (1875, 1781),\n",
       " (1049, 1917),\n",
       " (2842, 885),\n",
       " (1946, 1525),\n",
       " (369, 1449),\n",
       " (1246, 3374),\n",
       " (2351, 409),\n",
       " (279, 540),\n",
       " (1762, 2357),\n",
       " (2353, 1888),\n",
       " (2104, 90),\n",
       " (32, 1351),\n",
       " (16, 828),\n",
       " (2837, 574),\n",
       " (3372, 325),\n",
       " (1586, 467),\n",
       " (41, 671),\n",
       " (945, 113),\n",
       " (3372, 1960),\n",
       " (325, 1955),\n",
       " (1539, 2703),\n",
       " (1096, 3299),\n",
       " (359, 1955),\n",
       " (984, 1001),\n",
       " (1710, 1936),\n",
       " (3104, 1690),\n",
       " (1272, 380),\n",
       " (1325, 398),\n",
       " (260, 1810),\n",
       " (1746, 3173),\n",
       " (2332, 1949),\n",
       " (612, 1233),\n",
       " (3230, 3042),\n",
       " (1094, 213),\n",
       " (3219, 187),\n",
       " (264, 1033),\n",
       " (854, 3186),\n",
       " (1541, 1946),\n",
       " (3096, 2498),\n",
       " (1246, 912),\n",
       " (2237, 1816),\n",
       " (975, 3186),\n",
       " (2568, 1595),\n",
       " (3322, 3366),\n",
       " (607, 862),\n",
       " (1853, 3153),\n",
       " (796, 1087),\n",
       " (859, 2273),\n",
       " (2334, 175),\n",
       " (803, 333),\n",
       " (1158, 1729),\n",
       " (1748, 801),\n",
       " (259, 3307),\n",
       " (240, 3095),\n",
       " (1729, 2351),\n",
       " (1586, 2544),\n",
       " (1315, 1714),\n",
       " (176, 1595),\n",
       " (252, 2318),\n",
       " (2408, 2961),\n",
       " (1039, 3374),\n",
       " (1690, 230),\n",
       " (1128, 2885),\n",
       " (1595, 2434),\n",
       " (897, 257),\n",
       " (1657, 3005),\n",
       " (1599, 2854),\n",
       " (3146, 638),\n",
       " (25, 638),\n",
       " (1217, 984),\n",
       " (1399, 1520),\n",
       " (2316, 475),\n",
       " (90, 2368),\n",
       " (1258, 1936),\n",
       " (2768, 1256),\n",
       " (2832, 1438),\n",
       " (3346, 1816),\n",
       " (277, 2984),\n",
       " (3263, 497),\n",
       " (3178, 1327),\n",
       " (3104, 70),\n",
       " (1982, 1489),\n",
       " (938, 334),\n",
       " (1457, 1526),\n",
       " (2332, 1345),\n",
       " (1071, 1810),\n",
       " (2695, 2865),\n",
       " (1039, 612),\n",
       " (230, 1452),\n",
       " (1115, 386),\n",
       " (2334, 755),\n",
       " (2345, 2065),\n",
       " (1888, 3006),\n",
       " (3115, 710),\n",
       " (616, 3332),\n",
       " (2322, 599),\n",
       " (1267, 255),\n",
       " (255, 971),\n",
       " (408, 2984),\n",
       " (1161, 686),\n",
       " (3090, 2764),\n",
       " (607, 3346),\n",
       " (2469, 2544),\n",
       " (2294, 1979),\n",
       " (2220, 1850),\n",
       " (2805, 3356),\n",
       " (61, 670),\n",
       " (1647, 1888),\n",
       " (335, 1151),\n",
       " (1866, 729),\n",
       " (3366, 853),\n",
       " (1027, 1205),\n",
       " (729, 1408),\n",
       " (1095, 2853),\n",
       " (803, 905),\n",
       " (1285, 373),\n",
       " (3009, 3356),\n",
       " (3375, 1001),\n",
       " (257, 1129),\n",
       " (2183, 811),\n",
       " (736, 1508),\n",
       " (3366, 1520),\n",
       " (764, 1766),\n",
       " (1781, 3379),\n",
       " (3132, 2526),\n",
       " (1335, 1471),\n",
       " (789, 1275),\n",
       " (1086, 1891),\n",
       " (1716, 2434),\n",
       " (1655, 1910),\n",
       " (388, 1700),\n",
       " (3218, 1339),\n",
       " (1625, 1415),\n",
       " (819, 2168),\n",
       " (613, 691),\n",
       " (2854, 2883),\n",
       " (777, 439),\n",
       " (948, 2460),\n",
       " (2334, 2768),\n",
       " (530, 169),\n",
       " (942, 2133),\n",
       " (1157, 988),\n",
       " (537, 1219),\n",
       " (2150, 2768),\n",
       " (1662, 1325),\n",
       " (560, 1196),\n",
       " (1140, 2896),\n",
       " (1219, 303),\n",
       " (2345, 2541),\n",
       " (1664, 416),\n",
       " (1369, 350),\n",
       " (1097, 1435),\n",
       " (2172, 2832),\n",
       " (1737, 2434),\n",
       " (1687, 1372),\n",
       " (1350, 3307),\n",
       " (2894, 391),\n",
       " (1551, 2273),\n",
       " (2568, 2995),\n",
       " (439, 1888),\n",
       " (575, 728),\n",
       " (50, 2281),\n",
       " (3203, 1459),\n",
       " ...}"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "uniqueUserPairs"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "pickle.dump(uniqueUserPairs,open(\"uniqueUserPairs.pkl\",'wb'))\n",
    "pickle.dump(uniqueEventPairs,open(\"uniqueEventPairs.pkl\",'wb'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "number of records:3137973\n"
     ]
    }
   ],
   "source": [
    "lines = 0\n",
    "fin = open(\"events.csv\",\"r\")\n",
    "for line in fin:\n",
    "    cols = line.strip().split(\",\")\n",
    "    lines+=1\n",
    "fin.close()\n",
    "print(\"number of records:%d\" % lines)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "number of events in train & test: 13418\n"
     ]
    }
   ],
   "source": [
    "eventIndex = pickle.load(open(\"eventIndex.pkl\",'rb'))\n",
    "n_events = len(eventIndex)\n",
    "print(\"number of events in train & test: %d\" % n_events)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from utils import FeatureEng\n",
    "FE = FeatureEng()\n",
    "fin = open(\"events.csv\",\"rb\")\n",
    "fin.readline()\n",
    "eventPropMatrix = ss.dok_matrix((n_events,7))\n",
    "eventContMatrix = ss.dok_matrix((n_events,101))\n",
    "for line in fin.readlines():\n",
    "    cols = line.decode().strip().split(\",\")\n",
    "    eventId = str(cols[0])\n",
    "    if eventId in eventIndex:\n",
    "        i = eventIndex[eventId]\n",
    "\n",
    "        eventPropMatrix[i, 0] = FE.getJoinedYearMonth(cols[2]) # start_time\n",
    "        eventPropMatrix[i, 1] = FE.getFeatureHash(cols[3].encode('utf-8')) # city\n",
    "        eventPropMatrix[i, 2] = FE.getFeatureHash(cols[4].encode('utf-8')) # state\n",
    "        eventPropMatrix[i, 3] = FE.getFeatureHash(cols[5].encode('utf-8')) # zip\n",
    "        eventPropMatrix[i, 4] = FE.getFeatureHash(cols[6].encode('utf-8')) # country\n",
    "        eventPropMatrix[i, 5] = FE.getFloatValue(cols[7]) # lat\n",
    "        eventPropMatrix[i, 6] = FE.getFloatValue(cols[8]) # lon\n",
    "        \n",
    "        for j in range(9,110):\n",
    "            eventContMatrix[i,j-9] = cols[j]\n",
    "fin.close()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<13418x7 sparse matrix of type '<class 'numpy.float64'>'\n",
       "\twith 83211 stored elements in Dictionary Of Keys format>"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "eventPropMatrix"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<13418x101 sparse matrix of type '<class 'numpy.float64'>'\n",
       "\twith 199855 stored elements in Dictionary Of Keys format>"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "eventContMatrix"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "eventPropMatrix = normalize(eventPropMatrix, norm='l2',copy=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "sio.mmwrite(\"eventPropMatrix\",eventPropMatrix)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "eventContMatrix = normalize(eventContMatrix, norm = 'l2', copy=False)\n",
    "sio.mmwrite(\"eventContMatrix\", eventContMatrix)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "eventPropSim = ss.dok_matrix((n_events, n_events))\n",
    "eventContSim = ss.dok_matrix((n_events, n_events))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "uniqueEventPairs = pickle.load(open(\"uniqueEventPairs.pkl\",'rb'))\n",
    "for e1, e2 in uniqueEventPairs:\n",
    "    i=e1\n",
    "    j=e2\n",
    "    \n",
    "    if (i,j) not in eventPropSim:\n",
    "        epsim = ssd.correlation(eventPropMatrix.getrow(i).todense(),eventPropMatrix.getrow(j).todense())\n",
    "        eventPropSim[i,j]=epsim\n",
    "        eventPropSim[j,i]=epsim\n",
    "    \n",
    "    if (i,j) not in eventContSim:\n",
    "        ecsim = ssd.cosine(eventContMatrix.getrow(i).todense(),eventContMatrix.getrow(j).todense())\n",
    "        eventContSim[i,j]=ecsim\n",
    "        eventContSim[j,i]=ecsim\n",
    "sio.mmwrite(\"eventPropSim\",eventPropSim)\n",
    "sio.mmwrite(\"eventContSim\",eventContSim)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "number of users in train & test: 3391\n"
     ]
    }
   ],
   "source": [
    "userIndex = pickle.load(open(\"userIndex.pkl\",'rb'))\n",
    "n_users = len(userIndex)\n",
    "\n",
    "print(\"number of users in train & test: %d\" % n_users)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>user_id</th>\n",
       "      <th>locale</th>\n",
       "      <th>birthyear</th>\n",
       "      <th>gender</th>\n",
       "      <th>joinedAt</th>\n",
       "      <th>location</th>\n",
       "      <th>timezone</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>3197468391</td>\n",
       "      <td>id_ID</td>\n",
       "      <td>1993</td>\n",
       "      <td>male</td>\n",
       "      <td>2012-10-02T06:40:55.524Z</td>\n",
       "      <td>Medan  Indonesia</td>\n",
       "      <td>480.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>3537982273</td>\n",
       "      <td>id_ID</td>\n",
       "      <td>1992</td>\n",
       "      <td>male</td>\n",
       "      <td>2012-09-29T18:03:12.111Z</td>\n",
       "      <td>Medan  Indonesia</td>\n",
       "      <td>420.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>823183725</td>\n",
       "      <td>en_US</td>\n",
       "      <td>1975</td>\n",
       "      <td>male</td>\n",
       "      <td>2012-10-06T03:14:07.149Z</td>\n",
       "      <td>Stratford  Ontario</td>\n",
       "      <td>-240.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1872223848</td>\n",
       "      <td>en_US</td>\n",
       "      <td>1991</td>\n",
       "      <td>female</td>\n",
       "      <td>2012-11-04T08:59:43.783Z</td>\n",
       "      <td>Tehran  Iran</td>\n",
       "      <td>210.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>3429017717</td>\n",
       "      <td>id_ID</td>\n",
       "      <td>1995</td>\n",
       "      <td>female</td>\n",
       "      <td>2012-09-10T16:06:53.132Z</td>\n",
       "      <td>NaN</td>\n",
       "      <td>420.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      user_id locale birthyear  gender                  joinedAt  \\\n",
       "0  3197468391  id_ID      1993    male  2012-10-02T06:40:55.524Z   \n",
       "1  3537982273  id_ID      1992    male  2012-09-29T18:03:12.111Z   \n",
       "2   823183725  en_US      1975    male  2012-10-06T03:14:07.149Z   \n",
       "3  1872223848  en_US      1991  female  2012-11-04T08:59:43.783Z   \n",
       "4  3429017717  id_ID      1995  female  2012-09-10T16:06:53.132Z   \n",
       "\n",
       "             location  timezone  \n",
       "0    Medan  Indonesia     480.0  \n",
       "1    Medan  Indonesia     420.0  \n",
       "2  Stratford  Ontario    -240.0  \n",
       "3        Tehran  Iran     210.0  \n",
       "4                 NaN     420.0  "
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "users=pd.read_csv(\"users.csv\")\n",
    "users.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "FE=FeatureEng()\n",
    "n_cols=users.shape[1]-1\n",
    "cols=['LocaleId','BirthYearInt','GenderId','JoinedYearMonth','CountryId','TimezoneInt']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "userMatrix = ss.dok_matrix((n_users,n_cols))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "for u in range(users.shape[0]):\n",
    "    userId=str(users.loc[u,'user_id'])\n",
    "    if userId in userIndex:\n",
    "        i=userIndex[userId]\n",
    "        userMatrix[i,0]=FE.getLocaleId(users.loc[u,'locale'])\n",
    "        userMatrix[i,1]=FE.getBirthYearInt(users.loc[u,'birthyear'])\n",
    "        userMatrix[i,2]=FE.getGenderId(users.loc[u,'gender'])\n",
    "        userMatrix[i,3]=FE.getJoinedYearMonth(users.loc[u,'joinedAt'])\n",
    "        userMatrix[i,4]=FE.getCountryId(users.loc[u,'location'])\n",
    "        userMatrix[i,5]=FE.getTimezoneInt(users.loc[u,'timezone'])\n",
    "userMatrix=normalize(userMatrix,norm='l2',copy=False)\n",
    "sio.mmwrite('userMatrix',userMatrix)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "userSimMatrix = ss.dok_matrix((n_users,n_users))\n",
    "uniqueUserPairs=pickle.load(open(\"uniqueUserPairs.pkl\",\"rb\"))\n",
    "for i in range(0,n_users):\n",
    "    userSimMatrix[i,i]=1.0\n",
    "    \n",
    "for u1,u2 in uniqueUserPairs:\n",
    "    i=u1\n",
    "    j=u2\n",
    "\n",
    "    if (i,j) not in userSimMatrix:\n",
    "        usim = ssd.correlation(userMatrix.getrow(i).todense(),userMatrix.getrow(j).todense())\n",
    "        userSimMatrix[i,j]=usim\n",
    "        userSimMatrix[j,i]=usim\n",
    "sio.mmwrite(\"userSimMatrix\",userSimMatrix)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "matrix([[  6.66459631e-02,   9.76167342e-01,   4.90043847e-04,\n",
       "           1.71515346e-02,   0.00000000e+00,   2.05818416e-01]])"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "userMatrix.getrow(i).todense()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "matrix([[  6.65627595e-02,   9.74459221e-01,   4.89432055e-04,\n",
       "           1.71301219e-02,   5.87318466e-02,   2.05561463e-01]])"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "userMatrix.getrow(j).todense()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "userEventScores = sio.mmread(\"userEventScores\")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "eventsForUser = pickle.load(open(\"PE_eventsForUser.pkl\",\"rb\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "numFriends = np.zeros((n_users))\n",
    "userFriends = ss.dok_matrix((n_users,n_users))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[ 1065.    49.  3677. ...,   538.   964.   904.]\n",
      "sum: 3731377.0\n"
     ]
    }
   ],
   "source": [
    "fin=open(\"user_friends.csv\",\"rb\")\n",
    "fin.readline()\n",
    "for line in fin:\n",
    "    cols = line.decode().strip().split(\",\")\n",
    "    user = str(cols[0])\n",
    "    if user in userIndex:\n",
    "        friends = cols[1].split(\" \")\n",
    "        i = userIndex[user]\n",
    "        numFriends[i] = len(friends)\n",
    "        for friend in friends:\n",
    "            str_friend = str(friend)\n",
    "            if str_friend in userIndex:\n",
    "                j=userIndex[str_friend]\n",
    "                eventsForUser = userEventScores.getrow(j).todense()\n",
    "                score = eventsForUser.sum()/np.shape(eventsForUser)[1]\n",
    "                userFriends[i,j]+=score\n",
    "                userFriends[j,i]+=score\n",
    "fin.close()\n",
    "\n",
    "\n",
    "sumNumFriends = numFriends.sum(axis=0)\n",
    "print(numFriends)\n",
    "print(\"sum:\",sumNumFriends)\n",
    "numFriends = numFriends / sumNumFriends\n",
    "sio.mmwrite(\"numFriends\",np.matrix(numFriends))\n",
    "\n",
    "userFriends = normalize(userFriends,norm='l2',copy=False)\n",
    "sio.mmwrite(\"userFriends\",userFriends)\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "  (3, 3296)\t0.707106781187\n",
      "  (3, 1116)\t0.707106781187\n",
      "  (4, 2042)\t0.727606875109\n",
      "  (4, 510)\t0.485071250073\n",
      "  (4, 1468)\t0.485071250073\n",
      "  (8, 2129)\t1.0\n",
      "  (11, 53)\t0.970142500145\n",
      "  (11, 719)\t0.242535625036\n",
      "  (12, 2440)\t1.0\n",
      "  (16, 1395)\t1.0\n",
      "  (17, 1866)\t0.707106781187\n",
      "  (17, 2132)\t0.707106781187\n",
      "  (18, 1513)\t1.0\n",
      "  (20, 264)\t1.0\n",
      "  (21, 2371)\t1.0\n",
      "  (22, 3109)\t0.342997170285\n",
      "  (22, 198)\t0.514495755428\n",
      "  (22, 2117)\t0.514495755428\n",
      "  (22, 807)\t0.342997170285\n",
      "  (22, 1271)\t0.342997170285\n",
      "  (22, 3122)\t0.342997170285\n",
      "  (23, 1765)\t0.948683298051\n",
      "  (23, 978)\t0.316227766017\n",
      "  (24, 1759)\t0.408248290464\n",
      "  (24, 2225)\t0.816496580928\n",
      "  :\t:\n",
      "  (3372, 271)\t1.0\n",
      "  (3373, 3339)\t0.57735026919\n",
      "  (3373, 1318)\t0.57735026919\n",
      "  (3373, 457)\t0.57735026919\n",
      "  (3374, 496)\t1.0\n",
      "  (3375, 3152)\t1.0\n",
      "  (3376, 1331)\t1.0\n",
      "  (3379, 2941)\t0.707106781187\n",
      "  (3379, 2348)\t0.707106781187\n",
      "  (3380, 1949)\t0.264906471413\n",
      "  (3380, 2885)\t0.264906471413\n",
      "  (3380, 257)\t0.927172649946\n",
      "  (3382, 41)\t1.0\n",
      "  (3383, 189)\t0.707106781187\n",
      "  (3383, 2010)\t0.707106781187\n",
      "  (3385, 2187)\t0.514495755428\n",
      "  (3385, 1039)\t0.857492925713\n",
      "  (3387, 462)\t0.707106781187\n",
      "  (3387, 2221)\t0.707106781187\n",
      "  (3389, 1072)\t0.441726104299\n",
      "  (3389, 1629)\t0.331294578225\n",
      "  (3389, 276)\t0.441726104299\n",
      "  (3389, 2048)\t0.441726104299\n",
      "  (3389, 3051)\t0.441726104299\n",
      "  (3389, 3207)\t0.331294578225\n"
     ]
    }
   ],
   "source": [
    "print(userFriends)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "eventPopularity = ss.dok_matrix((n_events,1))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "f = open(\"event_attendees.csv\",\"rb\")\n",
    "f.readline()\n",
    "for line in f:\n",
    "    cols = line.decode().strip().split(\",\")\n",
    "    eventId = str(cols[0])\n",
    "    if eventId in eventIndex:\n",
    "        i = eventIndex[eventId]\n",
    "        eventPopularity[i,0] = len(cols[1].split(\" \"))-len(cols[4].split(\" \"))\n",
    "f.close()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "matrix([[  4.],\n",
       "        [  8.],\n",
       "        [ 16.],\n",
       "        ..., \n",
       "        [ -7.],\n",
       "        [ 68.],\n",
       "        [  8.]])"
      ]
     },
     "execution_count": 53,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "eventPopularity.todense()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "eventPopularity = normalize(eventPopularity,norm='l2',copy=False)\n",
    "\n",
    "sio.mmwrite(\"eventPopularity\", eventPopularity)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "matrix([[ 1.],\n",
       "        [ 1.],\n",
       "        [ 1.],\n",
       "        ..., \n",
       "        [-1.],\n",
       "        [ 1.],\n",
       "        [ 1.]])"
      ]
     },
     "execution_count": 55,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "eventPopularity.todense() #这个结果算得不对啊！"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 80,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from __future__ import division\n",
    "\n",
    "import pickle\n",
    "import numpy as np\n",
    "import scipy.io as sio\n",
    "import scipy.sparse as ss\n",
    "from numpy.random import random  \n",
    "from collections import defaultdict\n",
    "\n",
    "class RecommenderSystem:\n",
    "    def __init__(self):\n",
    "                \n",
    "        self.userIndex = pickle.load(open(\"userIndex.pkl\", 'rb'))\n",
    "        self.eventIndex = pickle.load(open(\"eventIndex.pkl\", 'rb'))\n",
    "        self.n_users = len(self.userIndex)\n",
    "        self.n_items = len(self.eventIndex)\n",
    "        self.userEventScores = sio.mmread(\"userEventScores\").todense()\n",
    "        self.itemsForUser = pickle.load(open(\"eventsForUser.pkl\", 'rb'))\n",
    "        self.usersForItem = pickle.load(open(\"usersForEvent.pkl\", 'rb'))\n",
    "     \n",
    "        self.userSimMatrix = sio.mmread(\"userSimMatrix\").todense()\n",
    "        self.eventPropSim = sio.mmread(\"eventPropSim\").todense()\n",
    "        self.eventContSim = sio.mmread(\"eventContSim\").todense()\n",
    "        self.numFriends = sio.mmread(\"numFriends\")\n",
    "        self.userFriends = sio.mmread(\"userFriends\").todense()\n",
    "        self.eventPopularity = sio.mmread(\"eventPopularity\").todense()\n",
    "        \n",
    "        self.init_SVD()\n",
    "        self.train_SVD(trainfile = \"train.csv\")\n",
    "        \n",
    "    def init_SVD(self, K=20):\n",
    "        self.K = K\n",
    "        self.bi = np.zeros(self.n_items)\n",
    "        self.bu = np.zeros(self.n_users)\n",
    "        \n",
    "        self.P = random((self.n_users,self.K))/10*(np.sqrt(self.K))\n",
    "        self.Q = random((self.K, self.n_items))/10*(np.sqrt(self.K))\n",
    "        \n",
    "    def train_SVD(self, trainfile = \"train.csv\", step =100, gamma =0.04, Lambda = 0.15):\n",
    "        print('SVD Train...')\n",
    "        ftrain = open(trainfile,\"r\")\n",
    "        ftrain.readline()\n",
    "        self.mu = 0\n",
    "        n_records = 0\n",
    "        uids = []\n",
    "        i_ids = []\n",
    "        R= np.zeros((self.n_users, self.n_items))\n",
    "        \n",
    "        for line in ftrain:\n",
    "            cols = line.strip().split(\",\")\n",
    "            u = self.userIndex[cols[0]]\n",
    "            i = self.eventIndex[cols[1]]\n",
    "            uids.append(u)\n",
    "            i_ids.append(i)\n",
    "            R[u,i] = int(cols[4])\n",
    "            self.mu += R[u,i]\n",
    "            n_records+=1\n",
    "        ftrain.close()\n",
    "        self.mu/=n_records\n",
    "        \n",
    "        for step in range(step):\n",
    "            rmse_sum = 0.0\n",
    "            kk = np.random.permutation(n_records)\n",
    "            for j in range(n_records):\n",
    "                index = kk[j]\n",
    "                u = uids[index]\n",
    "                i = i_ids[index]\n",
    "                eui = R[u,i] - self.pred_SVD(u,i)\n",
    "                rmse_sum+=eui**2\n",
    "                self.bu[u]+=gamma*eui-Lambda*self.bu[u]\n",
    "                self.bi[i]+=gamma*eui-Lambda*self.bi[i]\n",
    "                for k in range(self.K):\n",
    "                    self.P[u,k]+=gamma*eui*self.Q[k,i] - Lambda*self.P[u,k]\n",
    "                    self.Q[k,i]+=gamma*eui*self.P[u,k] - Lambda*self.Q[k,i]\n",
    "            gamma*=0.93\n",
    "        print(\"SVD trained\")\n",
    "        \n",
    "    def pred_SVD(self,uid,i_id):\n",
    "        ans = self.mu + self.bi[i_id] + self.bu[uid] + np.dot(self.P[uid,:],self.Q[:,i_id])\n",
    "        if ans >1:\n",
    "            return 1\n",
    "        elif ans<0:\n",
    "            return 0\n",
    "        return ans\n",
    "    \n",
    "    def sim_cal_UserCF(self, uid1, uid2):\n",
    "        si = {}\n",
    "        for item in self.itemsForUser[uid1]:\n",
    "            if item in self.itemForUser[uid2]:\n",
    "                si[item] = 1\n",
    "        n = len(si)\n",
    "        if(n==0):\n",
    "            similarity = 0\n",
    "            return similarity\n",
    "        s1 = np.array([self.userEventScores[uid1,item] for item in si])\n",
    "        s2 = np.array([self.userEventScores[uid2,item] for item in si])\n",
    "        \n",
    "        corr_pearson = np.corrcoef(s1,s2)[0,1]\n",
    "        similarity = 0.5+0.5*corr_pearson\n",
    "        return similarity\n",
    "        \n",
    "    def userCFReco(self,userId,eventId):\n",
    "        u = self.userIndex[userId]\n",
    "        i = self.eventIndex[eventId]\n",
    "        sim_acc = 0\n",
    "        rat_acc = 0\n",
    "        for user in self.usersForItem[i]:\n",
    "            sim = self.sim_cal_UserCF(uid1=user,uid2=u)\n",
    "            if sim == 0:\n",
    "                continue\n",
    "            rat_acc+=sim*self.userEventScores[user,i]\n",
    "            sim_acc+=sim\n",
    "        if sim_acc==0:\n",
    "            return self.mu\n",
    "        ans=rat_acc/sim_acc\n",
    "        if ans>1:\n",
    "            return 1\n",
    "        if ans<0:\n",
    "            return 0\n",
    "        return ans\n",
    "    \n",
    "    \n",
    "    def sim_cal_ItemCF(self, i_id1, i_id2):\n",
    "        si={}\n",
    "        for user in self.usersForItem[i_id1]:\n",
    "            if user in self.usersForItem[i_id2]:\n",
    "                si[user]=1\n",
    "        n=len(si)\n",
    "        if(n==0):\n",
    "            return 0\n",
    "        s1=np.array([self.userEventScores[u,i_id1] for u in si])\n",
    "        s2=np.array([self.userEventScores[u,i_id2] for u in si])\n",
    "        sum1=np.sum(s1)\n",
    "        sum2=np.sum(s2)\n",
    "        sum1Sq=np.sum(s1**2)\n",
    "        sum2Sq=np.sum(s2**2)\n",
    "        pSum=np.sum(s1*s2)\n",
    "        \n",
    "        num=pSum-(sum1*sum2/n)\n",
    "        den=np.sqrt((sum1Sq-sum1**2/n)*(sum2Sq-sum2**2/n))\n",
    "        if den==0:\n",
    "            return 0\n",
    "        return num/den\n",
    "    \n",
    "    def eventCFReco(self, userId,eventId):\n",
    "        u = self.userIndex[userId]\n",
    "        i = self.eventIndex[eventId]\n",
    "        sim_acc=0.0\n",
    "        rat_acc=0.0\n",
    "        for item in self.itemsForUser[u]:\n",
    "            sim = self.sim_cal_ItemCF(item,i)\n",
    "            rat_acc+=sim*self.userEventScores[u,item]\n",
    "            sim_acc+=sim\n",
    "            \n",
    "        if sim_acc==0:\n",
    "            return self.mu\n",
    "        if ans>1:\n",
    "            return 1\n",
    "        elif ans<0:\n",
    "            return 0\n",
    "        return ans\n",
    "    \n",
    "    def svdCFReco(self,userId,eventId):\n",
    "        u = self.userIndex[userId]\n",
    "        i = self.eventIndex[eventId]\n",
    "        return self.pred_SVD(u,i)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 81,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "SVD Train...\n",
      "SVD trained\n"
     ]
    }
   ],
   "source": [
    "RS=RecommenderSystem()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 82,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 82,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "RS.svdCFReco(\"7336598\",\"1980837904\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "class RecommnederSystem:\n",
    "    def __init__(self):\n",
    "        se"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 107,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "userIndex = pickle.load(open(\"PE_userIndex.pkl\",'rb'))\n",
    "eventIndex = pickle.load(open(\"PE_eventIndex.pkl\",'rb'))\n",
    "n_users = len(userIndex)\n",
    "n_items = len(eventIndex)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 108,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "userEventScores = sio.mmread(\"PE_userEventScores\").todense()\n",
    "itemsForUser = pickle.load(open(\"PE_eventsForUser.pkl\",'rb'))\n",
    "usersForItem = pickle.load(open(\"PE_usersForEvent.pkl\",'rb'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 109,
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'train_SVD' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-109-c62b4c1ee0f1>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mtrain_SVD\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mtrainfile\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;34m\"train.csv\"\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;31m#这行代码是什么意思？在哪里有定义？\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m: name 'train_SVD' is not defined"
     ]
    }
   ],
   "source": [
    "train_SVD(trainfile = \"train.csv\") #这行代码是什么意思？在哪里有定义？"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "ename": "FileNotFoundError",
     "evalue": "[Errno 2] No such file or directory: 'US_userSimMatrix'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mFileNotFoundError\u001b[0m                         Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-34-c4dcd17255f6>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0muserSimMatrix\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0msio\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mmmread\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"US_userSimMatrix\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mtodense\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;32mD:\\ProgramData\\Anaconda3\\lib\\site-packages\\scipy\\io\\mmio.py\u001b[0m in \u001b[0;36mmmread\u001b[1;34m(source)\u001b[0m\n\u001b[0;32m     74\u001b[0m         \u001b[0mMatrix\u001b[0m \u001b[0mMarket\u001b[0m \u001b[0mfile\u001b[0m\u001b[1;33m.\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m     75\u001b[0m     \"\"\"\n\u001b[1;32m---> 76\u001b[1;33m     \u001b[1;32mreturn\u001b[0m \u001b[0mMMFile\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mread\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0msource\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m     77\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m     78\u001b[0m \u001b[1;31m# -----------------------------------------------------------------------------\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mD:\\ProgramData\\Anaconda3\\lib\\site-packages\\scipy\\io\\mmio.py\u001b[0m in \u001b[0;36mread\u001b[1;34m(self, source)\u001b[0m\n\u001b[0;32m    409\u001b[0m             \u001b[0mMatrix\u001b[0m \u001b[0mMarket\u001b[0m \u001b[0mfile\u001b[0m\u001b[1;33m.\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    410\u001b[0m         \"\"\"\n\u001b[1;32m--> 411\u001b[1;33m         \u001b[0mstream\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mclose_it\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_open\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0msource\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    412\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    413\u001b[0m         \u001b[1;32mtry\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mD:\\ProgramData\\Anaconda3\\lib\\site-packages\\scipy\\io\\mmio.py\u001b[0m in \u001b[0;36m_open\u001b[1;34m(filespec, mode)\u001b[0m\n\u001b[0;32m    310\u001b[0m                     \u001b[0mstream\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mbz2\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mBZ2File\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mfilespec\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'rb'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    311\u001b[0m                 \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 312\u001b[1;33m                     \u001b[0mstream\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mopen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mfilespec\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mmode\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    313\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    314\u001b[0m             \u001b[1;31m# open for writing\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mFileNotFoundError\u001b[0m: [Errno 2] No such file or directory: 'US_userSimMatrix'"
     ]
    }
   ],
   "source": [
    "userSimMatrix = sio.mmread(\"US_userSimMatrix\").todense"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
